List<Task> taskList = taskService.createTaskQuery()
.orderByTaskName()
.desc()
.list();
assertEquals(6, taskList.size());
Task secondTask = taskList.remove(0);
assertEquals("Second Task", secondTask.getName());
for (Task task : taskList) {
assertEquals("First Task", task.getName());
}
Job job = managementService.createJobQuery()
.processInstanceId(pi.getId())
.singleResult();
assertNotNull(job);
// execute the timer
managementService.executeJob(job.getId());
// now there are 7 tasks
taskList = taskService.createTaskQuery()
.orderByTaskName()
.asc()
.list();
assertEquals(7, taskList.size());
// first task is the escalation task
Task escalationTask = taskList.remove(0);
assertEquals("Escalation Task 1", escalationTask.getName());
// complete it
taskService.complete(escalationTask.getId());
// now complete the remaining tasks
for (Task task : taskList) {
taskService.complete(task.getId());
}