Hi William,
I suppose this is what you want to do:
public class TaskCandidatesTest extends JbpmTestCase {
public void testCandidatePutsTaskBackInGroup() {
deployJpdlXmlString(
"<process name='CandidatePutsTaskBackInGroup'>" +
" <start>" +
" <transition to='review' />" +
" </start>" +
" <task name='review' " +
" candidate-groups='sales-dept'>" +
" <transition to='wait' />" +
" </task>" +
" <state name='wait'/>" +
"</process>"
);
ProcessInstance processInstance = executionService.startProcessInstanceByKey("CandidatePutsTaskBackInGroup");
String pid = processInstance.getId();
Task task = taskService.createTaskQuery().processInstanceId(pid).uniqueResult();
assertNull(task.getAssignee());
processEngine.execute(
new Command<Void>() {
public Void execute(Environment environment) throws Exception {
DbSessionImpl dbSessionImpl = environment.get(DbSessionImpl.class);
Session session = dbSessionImpl.getSession();
assertNotNull(session);
List<Task> list =
session.createQuery(
" select p.task from " + ParticipationImpl.class.getName() + " p "
+ " where p.groupId = :groupId ")
.setParameter("groupId", "sales-dept")
.list();
assertEquals(1, list.size());
assertEquals("review", list.get(0).getName());
return null;
}
}
);
taskService.takeTask(task.getId(), "johndoe");
task = taskService.createTaskQuery().processInstanceId(pid).uniqueResult();
assertEquals("johndoe", task.getAssignee());
taskService.assignTask(task.getId(), null);
task = taskService.getTask(task.getId());
assertNull(task.getAssignee());
}
}