Entity loader syntax

You use the entity loader files to define a set of entities that you load to a system and use in a test scenario for your solution.

Purpose

You define the entity loader in the Entity Loader editor. An entity loader file is used to define the entities that you want to load to a development server. To be loaded, an entity must have an ID.

Syntax

The following syntax describes the basic structure of an entity loader file.

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>;]

load <entity>[where <attribute> is <value>];

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 loading entities
Construct Description Example

load <entity> ;

Loads an entity. An entity can have one or more attributes, as well as collections of objects.

load a new product where 
   the id is 'banana' , 
   the description is "A banana" ;
Table 2. Optional constructs
Construct Description Example

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" ;

where <entity type> <entity id>

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

the customer is the customer "Jane Doe" 

where <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" 

Example

define 'Jane' as a new customer where 
	the customer id is "Jane@example.com",
	the first name is "Jane" , 
	the last name is "Doe" ;
		
define 'Janes Cart' as a new shopping cart where 
	the customer is Jane , 
	the shopping cart id is "1234567890" ; 
 
load Jane ; 

define 'banana' as "BANANA";

load a new product where 
	the id is 'banana' , 
	the description is "A banana" ;

add the product identified by 'banana' to the products of 'Janes Cart' ; 

load 'Janes Cart' ;