@Test @org.activiti.engine.test.Deployment public void testNonInterruptingMoreComplex2(){
  ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("nonInterruptingWithInclusiveMerge");
  assertNotNull(processInstance);
  assertFalse(processInstance.isEnded());
  List<Task> tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(2,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("B",tasks.get(1).getName());
  assertEquals(2,managementService.createTimerJobQuery().count());
  taskService.complete(tasks.get(0).getId());
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(1,tasks.size());
  assertEquals("B",tasks.get(0).getName());
  assertEquals(1,managementService.createTimerJobQuery().count());
  taskService.complete(tasks.get(0).getId());
  assertEquals(0,managementService.createTimerJobQuery().count());
  assertEquals(0,runtimeService.createExecutionQuery().count());
  processInstance=runtimeService.startProcessInstanceByKey("nonInterruptingWithInclusiveMerge");
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(2,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("B",tasks.get(1).getName());
  assertEquals(2,managementService.createTimerJobQuery().count());
  taskService.complete(tasks.get(1).getId());
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(1,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals(1,managementService.createTimerJobQuery().count());
  String jobId=managementService.createTimerJobQuery().singleResult().getId();
  managementService.moveTimerToExecutableJob(jobId);
  managementService.executeJob(jobId);
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(3,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("C",tasks.get(1).getName());
  assertEquals("D",tasks.get(2).getName());
  assertEquals(1,managementService.createTimerJobQuery().count());
  jobId=managementService.createTimerJobQuery().singleResult().getId();
  managementService.moveTimerToExecutableJob(jobId);
  managementService.executeJob(jobId);
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(4,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("C",tasks.get(1).getName());
  assertEquals("D",tasks.get(2).getName());
  assertEquals("G",tasks.get(3).getName());
  taskService.complete(taskService.createTaskQuery().taskName("C").singleResult().getId());
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(3,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("D",tasks.get(1).getName());
  assertEquals("G",tasks.get(2).getName());
  taskService.complete(taskService.createTaskQuery().taskName("D").singleResult().getId());
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(2,tasks.size());
  assertEquals("A",tasks.get(0).getName());
  assertEquals("G",tasks.get(1).getName());
  taskService.complete(taskService.createTaskQuery().taskName("A").singleResult().getId());
  tasks=taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list();
  assertEquals(1,tasks.size());
  assertEquals("G",tasks.get(0).getName());
  taskService.complete(taskService.createTaskQuery().taskName("G").singleResult().getId());
  assertEquals(0,runtimeService.createExecutionQuery().count());
}
