" </task-node>" +
" <state name='b' />" +
"</process-definition>"
);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
processInstance.signal();
TaskMgmtInstance tmi = (TaskMgmtInstance) processInstance.getInstance(TaskMgmtInstance.class);
assertNotNull(tmi);
assertEquals(3, tmi.getTaskInstances().size());
// only before the first task, the token should be in a
assertSame(processDefinition.getNode("a"), token.getNode());
Iterator iter = tmi.getTaskInstances().iterator();
while (iter.hasNext()) {
// before every task is completed, check if the token is still in node a
TaskInstance taskInstance = (TaskInstance) iter.next();
taskInstance.end();
// after each task, check if the token remains in a
assertSame(processDefinition.getNode("a"), token.getNode());
}
// signal='never' is used when an external trigger should trigger execution, without
// any relation to the tasks finishing
processInstance.signal();
assertSame(processDefinition.getNode("b"), token.getNode());
}