);
jbpmContext.deployProcessDefinition(superDefinition);
newTransaction();
ProcessInstance superInstance = jbpmContext.newProcessInstanceForUpdate("super");
ContextInstance superContext = superInstance.getContextInstance();
superContext.setVariable("a", "value a");
superContext.setVariable("b", "value b");
superInstance.signal();
commitAndCloseSession();
try {
SchedulerThread schedulerThread = new SchedulerThread(jbpmConfiguration);
schedulerThread.executeTimers();
} finally {
beginSessionTransaction();
}
superInstance = jbpmContext.loadProcessInstance(superInstance.getId());
assertEquals("async", superInstance.getRootToken().getNode().getName());
commitAndCloseSession();
try {
CommandExecutorThread commandExecutorThread = new CommandExecutorThread(jbpmConfiguration);
commandExecutorThread.executeCommand();
} finally {
beginSessionTransaction();
}
List taskInstances = taskMgmtSession.findTaskInstances("victim");
assertEquals(1, taskInstances.size());
TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
taskInstance.setVariable("a", "value a updated");
taskInstance.setVariable("b", "value b updated");
taskInstance.end();
jbpmContext.save(taskInstance);
long taskInstanceId = taskInstance.getId();
long tokenId = taskInstance.getToken().getId();
newTransaction();
taskInstance = jbpmContext.loadTaskInstance(taskInstanceId);
assertEquals("value a updated", taskInstance.getVariable("a"));
assertEquals("value b updated", taskInstance.getVariable("b"));
Token token = jbpmContext.loadToken(tokenId);
ContextInstance subContextInstance = token.getProcessInstance().getContextInstance();
assertEquals("value a", subContextInstance.getVariable("a"));
assertEquals("value b updated", subContextInstance.getVariable("b"));
}