Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
Task task = taskService.createTaskQuery().taskDefinitionKey("innerTask1").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("innerTask2").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask1").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask2").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
// Case 2: fire outer tasks first
pi = runtimeService.startProcessInstanceByKey("nonInterruptingTimer");
job = managementService.createJobQuery().singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask1").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask2").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("innerTask1").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("innerTask2").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}