A simple process definition of a couple of tasks:
"<process-definition name='threeStep'>" +
 " <start-state name='start'>" +
 " <transition to='s1' />" +
 " </start-state>" +
 " <task-node name='s1'>" +
 " <task name='t1'/>" +
 " <transition to='s2' />" +
 " </task-node>" +
 " <task-node name='s2'>" +
 " <task name='t2'/>" +
 " <transition to='s3' />" +
 " </task-node>" +
 " <end-state name='s3' />" +
 "</process-definition>"
Create this as an instance and signal() to start. Then, using the following gives the outstanding task instance t1 
processInstance.getTaskMgmtInstance().getUnfinishedTasks(processInstance.getRootToken())
Use signal() to continue and then pauses at the next task, the line above now show t1 & t2 as unfinished. How do you mark the first task as finished? 
I've tried by obtaining the task instance and using end() but this complains 
the task is already ended: 
Collection c = processInstance.getTaskMgmtInstance().getUnfinishedTasks(processInstance.getRootToken());
 for (Iterator i = c.iterator(); i.hasNext(); ) {
 TaskInstance ti = (TaskInstance) i.next();
 ti.setEnd(now);
 ti.end(); // Mark complete
 }
What is the correct way to interact with a task instance to ensure the state is set correctly before transitioning?