It is possible to initialize entities from your BOM project one by one by using the
TestDriver loadEntity (Entity entity) method.
Before you begin
You must create a test client project before you can use the methods of the
TestDriver class.
Procedure
- Import the Java™ packages for your model into the .java file that contains
the TestDriver class in the test client project. For example:
import com.example.model.ConceptFactory;
import com.example.model.Customer;
import com.example.model.CreateCartEntity;
import com.example.model.ShoppingCart;
- Define a method to load your entities into the grid and code a connection to your solution
BOM. For example, the following loadCustomer method loads a
Customer entity named
Jack
Smith
:private void loadCustomer() throws Exception {
Customer customer = testDriver.getConceptFactory(ConceptFactory.class).createCustomer("Smith");
customer.setFirstName("Jack");
customer.setLastName("Smith");
customer.setLoyaltyCardOwner(true);
testDriver.loadEntity(customer);
}
- Check that the entity is created.
For example, the following code checks that the Customer entity is created.
if (testDriver.waitUntilSolutionIdle(10) == true) {
ShoppingCart cart =
testDriver.fetchEntity(ShoppingCart.class, shoppingCartId);
assertNotNull(cart);
}
- In Insight Designer, run the test client
as a JUnit test.
What to do next
The REST API is a quick way to validate that entities are loaded into the grid. Enter REST
URLs in the address field of your browser to access the stored solutions and entities in the server.
The following URL examples show how you can validate that your solution is deployed and the Customer
is created:
- To list all deployed solutions:
http://localhost:9080/ibm/ia/rest/solutions
- To list all entity types that are managed by your solution:
http://localhost:9080/ibm/ia/rest/solutions/MySolution/entity-types
- To list all instances of a specific entity type in your solution:
http://localhost:9080/ibm/ia/rest/solutions/MySolution/entity-types/com.example.model.Customer/entities