parameters.put("f", myEntityOnlyFields);
parameters.put("z", myVariableSerializable);
long processInstanceId = ksession.startProcess( "com.sample.ruleflow", parameters ).getId();
TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
WorkItem workItem = handler.getWorkItem();
assertNotNull( workItem );
List<?> result = emf.createEntityManager().createQuery("select i from MyEntity i").getResultList();
assertEquals(1, result.size());
result = emf.createEntityManager().createQuery("select i from MyEntityMethods i").getResultList();
assertEquals(1, result.size());
result = emf.createEntityManager().createQuery("select i from MyEntityOnlyFields i").getResultList();
assertEquals(1, result.size());
logger.info("### 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.info("### Completing first work item ###");
ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
workItem = handler.getWorkItem();
assertNotNull( workItem );
logger.info("### 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 new String", processInstance.getVariable("a"));
assertEquals("This is a new test Entity", ((MyEntity) processInstance.getVariable("b")).getTest());
assertEquals("This is a new test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("c")).getText());
logger.info("### Completing second work item ###");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
workItem = handler.getWorkItem();
assertNotNull(workItem);
logger.info("### 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.info("### Completing third work item ###");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
workItem = handler.getWorkItem();
assertNull(workItem);