// Start process
long processInstanceId = ksession.startProcess( "com.sample.ruleflow", parameters ).getId();
TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
WorkItem workItem = handler.getWorkItem();
assertNotNull( workItem );
// Test results
List<?> result = getEntitiesFromCache(cache, "myEntity", MyEntity.class);
assertEquals(origNumMyEntities + 1, result.size());
result = getEntitiesFromCache(cache, "myEntityMethods", MyEntityMethods.class);
assertEquals(origNumMyEntityMethods + 1, result.size());
result = getEntitiesFromCache(cache, "myEntityOnlyFields", MyEntityOnlyFields.class);
assertEquals(origNumMyEntityOnlyFields + 1, result.size());
logger.debug("### Retrieving process instance ###");
ksession = reloadSession( ksession, kbase, env );
WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance( processInstanceId );
assertNotNull( processInstance );
assertEquals("SomeString", processInstance.getVariable("x"));
assertEquals("This is a test Entity with annotation in fields", ((MyEntity) processInstance.getVariable("y")).getTest());
assertEquals("This is a test Entity with annotations in methods", ((MyEntityMethods) processInstance.getVariable("m")).getTest());
assertEquals("This is a test Entity with annotations in fields and without accesors methods", ((MyEntityOnlyFields) processInstance.getVariable("f")).test);
assertEquals("This is a test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("z")).getText());
assertNull(processInstance.getVariable("a"));
assertNull(processInstance.getVariable("b"));
assertNull(processInstance.getVariable("c"));
logger.debug("### Completing first work item ###");
ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
workItem = handler.getWorkItem();
assertNotNull( workItem );
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
logger.debug("### Retrieving process instance ###");
ksession = reloadSession( ksession, kbase, env);
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance(processInstanceId);
assertNotNull(processInstance);
assertEquals("SomeString", processInstance.getVariable("x"));
assertEquals("This is a test Entity with annotation in fields", ((MyEntity) processInstance.getVariable("y")).getTest());
assertEquals("This is a test Entity with annotations in methods", ((MyEntityMethods) processInstance.getVariable("m")).getTest());
assertEquals("This is a test Entity with annotations in fields and without accesors methods", ((MyEntityOnlyFields) processInstance.getVariable("f")).test);
assertEquals("This is a test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("z")).getText());
assertEquals("Some changed String", processInstance.getVariable("a"));
assertEquals("This is a changed test Entity", ((MyEntity) processInstance.getVariable("b")).getTest());
assertEquals("This is a changed test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("c")).getText());
logger.debug("### Completing third work item ###");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
workItem = handler.getWorkItem();
assertNotNull(workItem);
logger.debug("### Retrieving process instance ###");
ksession = reloadSession( ksession, kbase, env);
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance(processInstanceId);
assertNotNull(processInstance);
assertEquals("SomeString", processInstance.getVariable("x"));
assertEquals("This is a test Entity with annotation in fields", ((MyEntity) processInstance.getVariable("y")).getTest());
assertEquals("This is a test Entity with annotations in methods", ((MyEntityMethods) processInstance.getVariable("m")).getTest());
assertEquals("This is a test Entity with annotations in fields and without accesors methods", ((MyEntityOnlyFields) processInstance.getVariable("f")).test);
assertEquals("This is a test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("z")).getText());
assertEquals("Some changed String", processInstance.getVariable("a"));
assertEquals("This is a changed test Entity", ((MyEntity) processInstance.getVariable("b")).getTest());
assertEquals("This is a changed test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("c")).getText());
logger.debug("### Completing third work item ###");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
workItem = handler.getWorkItem();
assertNull(workItem);
ksession = reloadSession( ksession, kbase, env );