taskService.complete(taskBeforeSubProcess.getId());
if(processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// called process started so businesskey should be written in history
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).singleResult();
assertEquals(businessKey, hpi.getBusinessKey());
assertEquals(2, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).list().size());
}
// one task in sub process should be active after starting sub process instance
taskQuery = taskService.createTaskQuery();
Task taskInSubProcess = taskQuery.singleResult();
assertEquals("Task in subprocess", taskInSubProcess.getName());
ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().processInstanceId(taskInSubProcess.getProcessInstanceId()).singleResult();
assertEquals("myBusinessKey", subProcessInstance.getBusinessKey());
taskService.complete(taskInSubProcess.getId());
// task after sub process in super process
taskQuery = taskService.createTaskQuery();
Task taskAfterSubProcess = taskQuery.singleResult();
assertEquals("Task after subprocess", taskAfterSubProcess.getName());
taskService.complete(taskAfterSubProcess.getId());
assertProcessEnded(processInstance.getId());
assertEquals(0, runtimeService.createExecutionQuery().list().size());
if(processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).finished().singleResult();
assertEquals(businessKey, hpi.getBusinessKey());
assertEquals(2, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).finished().list().size());
}
}