// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingStartTimerEventWithTwoEventSubProcesses");
// check if execution exists
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
assertEquals(1, executionQuery.count());
// check if user task exists
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
assertEquals(1, taskQuery.count());
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(2, jobQuery.count());
// get all timer jobs ordered by dueDate
List<Job> orderedJobList = jobQuery.orderByJobDuedate().asc().list();
// execute first timer job
managementService.executeJob(orderedJobList.get(0).getId());
assertEquals(1, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
DummyServiceTask.wasExecuted = false;
// check if user task still exists because timer start event is non
// interrupting
assertEquals(1, taskQuery.count());
// check if execution still exists because timer start event is non
// interrupting
assertEquals(1, executionQuery.count());
// execute second timer job
managementService.executeJob(orderedJobList.get(1).getId());
assertEquals(0, jobQuery.count());
assertEquals(true, DummyServiceTask.wasExecuted);
// check if user task still exists because timer start event is non
// interrupting
assertEquals(1, taskQuery.count());
// check if execution still exists because timer event is non interrupting
assertEquals(1, executionQuery.count());
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
assertEquals(1, processInstanceQuery.count());
}