WorkItem workItem = handler.getWorkItem();
assertNotNull( workItem );
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", ((MyEntity) processInstance.getVariable("y")).getTest());
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 ###");
Map<String, Object> results = new HashMap<String, Object>();
results.put("zeta", processInstance.getVariable("z"));
results.put("equis", processInstance.getVariable("x")+"->modifiedResult");
ksession.getWorkItemManager().completeWorkItem( workItem.getId(), results );
workItem = handler.getWorkItem();
assertNotNull( workItem );
logger.debug("### Retrieving process instance ###");
ksession = reloadSession( ksession, kbase, env );
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance(processInstanceId);
assertNotNull(processInstance);
logger.debug("######## Getting the already Persisted Variables #########");
assertEquals("SomeString->modifiedResult", processInstance.getVariable("x"));
assertEquals("This is a test Entity", ((MyEntity) processInstance.getVariable("y")).getTest());
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.debug("### Completing second work item ###");
results = new HashMap<String, Object>();
results.put("zeta", processInstance.getVariable("z"));
results.put("equis", processInstance.getVariable("x"));
ksession.getWorkItemManager().completeWorkItem( workItem.getId(), results );
workItem = handler.getWorkItem();
assertNotNull(workItem);
logger.debug("### Retrieving process instance ###");
ksession = reloadSession( ksession, kbase, env );
processInstance = (WorkflowProcessInstance)
ksession.getProcessInstance(processInstanceId);
assertNotNull(processInstance);
assertEquals("SomeString->modifiedResult", processInstance.getVariable("x"));
assertEquals("This is a test Entity", ((MyEntity) processInstance.getVariable("y")).getTest());
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 ###");
results = new HashMap<String, Object>();
results.put("zeta", processInstance.getVariable("z"));
results.put("equis", processInstance.getVariable("x"));
ksession.getWorkItemManager().completeWorkItem( workItem.getId(), results );
workItem = handler.getWorkItem();
assertNull(workItem);