.singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// Subprocess execution is created
Execution execution = runtimeService.createExecutionQuery().parentId(processInstance.getId()).singleResult();
assertNotNull(execution);
assertEquals(5, listener.getEventsReceived().size());
activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_COMPLETED, activityEvent.getType());
assertEquals("shipOrder", activityEvent.getActivityId());
assertEquals(processInstance.getId(), activityEvent.getExecutionId());
assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
assertEquals("subProcess", activityEvent.getActivityId());
assertEquals(execution.getId(), activityEvent.getExecutionId());
assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(2);
assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
assertEquals("subProcessStart", activityEvent.getActivityId());
assertEquals(execution.getId(), activityEvent.getExecutionId());
assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(3);
assertEquals(ActivitiEventType.ACTIVITY_COMPLETED, activityEvent.getType());
assertEquals("subProcessStart", activityEvent.getActivityId());
assertEquals(execution.getId(), activityEvent.getExecutionId());
assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(4);
assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
assertEquals("subTask", activityEvent.getActivityId());
assertEquals(execution.getId(), activityEvent.getExecutionId());
assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
listener.clearEventsReceived();
// Check gateway and intermediate throw event
Task subTask = taskService.createTaskQuery().executionId(execution.getId()).singleResult();
assertNotNull(subTask);
taskService.complete(subTask.getId());
assertEquals(10, listener.getEventsReceived().size());