Event sequence syntax

You use the event sequence file to define a set of events that you can emit to the system and use in a test scenario for your solution.

Purpose

You define the event sequence in the Event Sequence editor. An event sequence file is used to define the events that you want to emit and the attributes that compose the events. To be emitted, an event needs the following elements:
  • A type.
  • A timestamp.

Syntax

The following syntax shows all of the constructs you can add to a common definitions file. All of the constructs are optional. Use as many constructs as it takes to define a test scenario or reusable subset of a scenario.

[using definitions from: 
   - "<common definitions file>" ;]

[define <variable> as <value> [where 
   <entity type> <entity id>
   <entity type> identified by <entity id>] ;]

[add <value> to <collection> ;]
[clear <list> of <object> ;]
[make it <true or false> that <object> is <boolean field>;]
[remove <an object> from <a list> ;]
[set <attribute> of <object> to <value>;]

emit [<event>] [where <attribute> is <value>];
emit [<event>] [where <attribute> is <value>][ , time-stamped <date & time>] ;
emit [<event>] [where <attribute> is <value>][, time-stamped <calendar duration> earlier|later] ; 
 

If you use the optional using definitions from : <common definitions file> construct, it must be the first phrase in the test files. Do not create circular dependencies by which two common definitions files reference each other.

Table 1. Constructs for emitting events
Construct Description Example

emit <event> ;

Emits an event. An event must have a timestamp, and can have one or more attributes, as well as collections of objects.

emit a new customer registration event where 
the customer is the customer "Jane Doe" ,
time-stamped 2/20/2015 3:00:00 PM ;

emit <an event> , time-stamped <date & time> ;

Emits an event with an absolute timestamp.

emit a new customer registration event ,
time-stamped 3/20/2015 2:04:27 PM ;

emit <an event> , time-stamped <calendar duration> earlier ;

Emits an event with a timestamp that is relative to the timestamp of the previous event, according to the order of the events order of definition in the file.

emit a new customer registration event ,
time-stamped 30 minutes earlier ;

emit <an event> , time-stamped <calendar duration> later ;

Emits an event with a timestamp that is relative to the timestamp of the previous event, according to the order of the events order of definition in the file.

emit a new customer registration event
time-stamped 2 hours 1 minute later ;
Table 2. Optional constructs
Construct Description Example

<entity type> <entity id>

Short construct that specifies a relationship between the bound entity and the event.

the customer is the customer "Jane Doe" 

<entity type> identified by <entity id>

Specifies a relationship between the bound entity and the event.

the customer is the customer identified by "Jane Doe" 

add <value> to <collection> ;

Adds an object to a collection. The target of this construct cannot be a relationship.

add ( a new item where
the amount is 200 ,
the status is "expensive" )
to the items of 'the purchase' ;

define <variable> as <value> ;

Defines a variable. The value of the variable can be an object or a constant. Variables can be used in the definition of the event emission.

define 'customer name' as "Jane Doe" ;

clear <list> of <object> ;

Clears a collection or removes a relationship between two objects. The clear <list> keywords specify the collection or types of relationship, and the of <object> keywords define the entity or event that you want to clear from the relationship or collection.

clear the items of 'purchase1' ;

make it <true or false> that <object> is <boolean field>;

Replaces the value of a boolean attribute.

make it true that 'purchase1' is special delivery  ;

remove <an object> from <a list> ;

Removes an item from a list. The remove <object> keywords specify the object that you want to remove, and the from <a list> keywords define the collection from which you want to remove the object.

remove 'milk' from the items of 'purchase1' ;

set <attribute> of <object> to <value>;

Replaces the value of an attribute with the value of another type. Values can be simple, relationship, geospatial, or complex types.

set the customer of the 'purchase1' to 'example.com'  ;

using definitions from: - "<common definitions file>" ;

Specifies the common definitions file or files from which an entity loader, event sequence, or common definitions file uses the definitions. When you use this construct, it must be used in the header of the file and precede all of the other constructs.

using definitions from: 
   - "customer_ids" 
   - "items" ;

Examples

The following example shows a single event with an absolute timestamp.

emit a new transaction where 
   the account is the account identified by "1234" ,
   the amount is 100 ,
   time-stamped 3/24/2015 10:36:12 AM ;

The following example shows a more complex event sequence with three events. The example also includes definitions of variables, and a collection of the account objects. The first event is a transaction event with several attributes, and has an absolute timestamp. The variable the customer is used in the definition of the customer subscription variable. In the next construct, an account is added to the collection of accounts of this customer subscription. Finally, two events are written with relative timestamps. The subscription event is time-stamped 5 minutes after the transaction event, and the authorization response event is time-stamped 15 minutes before the subscription event. The subscription event is emitted after the authorization response event, based on their order in the file, and regardless of their timestamps.

emit a new transaction where 
   the account is the account identified by "1234",
   the amount is 13000 , 	 
   the country code is "FR" , 
   time-stamped 3/24/2015 10:36:12 AM ;
	
define 'the customer' as the customer identified by "jane@doe.com" ;

define 'the subscription' as a new customer subscription where 
   the customer is 'the customer';

add the account "98098432" to
   the accounts of 'the subscription';

emit 'the subscription' ,
   time-stamped 5 minutes later;
	 
emit a new authorization response where 
   the message is "Approved" ,
   time-stamped 15 minutes earlier ;