code: @Deployment public void testTerminateWithSubProcess2() throws Exception {
    ProcessInstance pi=runtimeService.startProcessInstanceByKey("terminateEndEventExample");
    Task task=taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preNormalEnd").singleResult();
    taskService.complete(task.getId());
    task=taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preTerminateEnd").singleResult();
    assertNotNull(task);
    taskService.complete(task.getId());
    assertProcessEnded(pi.getId());
    assertHistoricProcessInstanceDetails(pi);
    assertHistoricProcessInstanceDeleteReason(pi,null);
    assertHistoricTasksDeleteReason(pi,null,"check before termination","check before end");
    assertHistoricActivitiesDeleteReason(pi,null,"preNormalEnd","preTerminateEnd");
    assertHistoricActivitiesDeleteReason(pi,DeleteReason.TERMINATE_END_EVENT,"SubProcess_1");
  }
  