use of org.activiti.engine.delegate.event.impl.ActivitiActivityCancelledEventImpl in project Activiti by Activiti.
the class ProcessInstanceEventsTest method testProcessInstanceTerminatedEvents_terminateInParentProcess.
@Deployment(resources = { "org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInParentProcess.bpmn", "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceTerminatedEvents_terminateInParentProcess() throws Exception {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateParentProcess");
// should terminate the called process and continue the parent
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preTerminateEnd").singleResult();
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
List<ActivitiEvent> processTerminatedEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
assertEquals("There should be exactly one ActivitiEventType.PROCESS_TERMINATED event after the task complete.", 1, processTerminatedEvents.size());
ActivitiProcessCancelledEventImpl processCancelledEvent = (ActivitiProcessCancelledEventImpl) processTerminatedEvents.get(0);
assertThat(processCancelledEvent.getProcessInstanceId(), is(pi.getProcessInstanceId()));
assertThat(processCancelledEvent.getProcessDefinitionId(), containsString("terminateParentProcess"));
List<ActivitiEvent> activityTerminatedEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
assertThat("3 activities must be cancelled.", activityTerminatedEvents.size(), is(3));
ActivitiActivityCancelledEventImpl activityEvent = (ActivitiActivityCancelledEventImpl) activityTerminatedEvents.get(0);
assertThat("The user task must be terminated in the called sub process.", activityEvent.getActivityId(), is("theTask"));
assertThat("The cause must be terminate end event", ((ActivityImpl) activityEvent.getCause()).getId(), is("EndEvent_3"));
activityEvent = (ActivitiActivityCancelledEventImpl) activityTerminatedEvents.get(1);
assertThat("The call activity must be terminated", activityEvent.getActivityId(), is("CallActivity_1"));
assertThat("The cause must be terminate end event", ((ActivityImpl) activityEvent.getCause()).getId(), is("EndEvent_3"));
activityEvent = (ActivitiActivityCancelledEventImpl) activityTerminatedEvents.get(2);
assertThat("The gateway must be terminated", activityEvent.getActivityId(), is("ParallelGateway_1"));
assertThat("The cause must be terminate end event", ((ActivityImpl) activityEvent.getCause()).getId(), is("EndEvent_3"));
}
use of org.activiti.engine.delegate.event.impl.ActivitiActivityCancelledEventImpl in project Activiti by Activiti.
the class ProcessInstanceEventsTest method testProcessInstanceTerminatedEvents.
@Deployment(resources = "org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.testProcessTerminate.bpmn")
public void testProcessInstanceTerminatedEvents() throws Exception {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample");
long executionEntities = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).count();
assertEquals(3, executionEntities);
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preTerminateTask").singleResult();
taskService.complete(task.getId());
List<ActivitiEvent> processTerminatedEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
assertEquals("There should be exactly one ActivitiEventType.PROCESS_CANCELLED event after the task complete.", 1, processTerminatedEvents.size());
ActivitiProcessCancelledEventImpl activitiEvent = (ActivitiProcessCancelledEventImpl) processTerminatedEvents.get(0);
assertThat(activitiEvent.getProcessInstanceId(), is(pi.getProcessInstanceId()));
assertThat(((ActivityImpl) activitiEvent.getCause()).getId(), is("EndEvent_2"));
List<ActivitiEvent> activityTerminatedEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
assertThat("There should be exactly two ActivitiEventType.ACTIVITY_CANCELLED event after the task complete.", activityTerminatedEvents.size(), is(2));
ActivitiActivityCancelledEventImpl activityEvent = (ActivitiActivityCancelledEventImpl) activityTerminatedEvents.get(0);
assertThat("The user task must be terminated", activityEvent.getActivityId(), is("preNormalTerminateTask"));
assertThat("The cause must be terminate end event", ((ActivityImpl) activityEvent.getCause()).getId(), is("EndEvent_2"));
activityEvent = (ActivitiActivityCancelledEventImpl) activityTerminatedEvents.get(1);
assertThat("The gateway must be terminated", activityEvent.getActivityId(), is("ParallelGateway_1"));
assertThat("The cause must be terminate end event", ((ActivityImpl) activityEvent.getCause()).getId(), is("EndEvent_2"));
}
Aggregations