Search in sources :

Example 1 with ActivitiProcessCancelledEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl 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);
    assertThat(processTerminatedEvents).as("There should be exactly one ActivitiEventType.PROCESS_TERMINATED event after the task complete.").hasSize(1);
    ActivitiProcessCancelledEventImpl processCancelledEvent = (ActivitiProcessCancelledEventImpl) processTerminatedEvents.get(0);
    assertThat(processCancelledEvent.getProcessInstanceId()).isEqualTo(pi.getProcessInstanceId());
    assertThat(processCancelledEvent.getProcessDefinitionId()).contains("terminateParentProcess");
    List<ActivitiEvent> activityTerminatedEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(activityTerminatedEvents).as("3 activities must be cancelled.").hasSize(3);
    for (ActivitiEvent event : activityTerminatedEvents) {
        ActivitiActivityCancelledEventImpl activityEvent = (ActivitiActivityCancelledEventImpl) event;
        if (activityEvent.getActivityId().equals("theTask")) {
            assertThat(activityEvent.getActivityId()).as("The user task must be terminated in the called sub process.").isEqualTo("theTask");
            assertThat(activityEvent.getCause()).as("The cause must be terminate end event").isEqualTo("Terminated by end event: EndEvent_3");
        } else if (activityEvent.getActivityId().equals("CallActivity_1")) {
            assertThat(activityEvent.getActivityId()).as("The call activity must be terminated").isEqualTo("CallActivity_1");
            assertThat(activityEvent.getCause()).as("The cause must be terminate end event").isEqualTo("Terminated by end event: EndEvent_3");
        } else if (activityEvent.getActivityId().equals("EndEvent_3")) {
            assertThat(activityEvent.getActivityId()).as("The end event must be terminated").isEqualTo("EndEvent_3");
            assertThat(activityEvent.getCause()).as("The cause must be terminate end event").isEqualTo("Terminated by end event: EndEvent_3");
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) ActivitiActivityCancelledEventImpl(org.activiti.engine.delegate.event.impl.ActivitiActivityCancelledEventImpl) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) ActivitiProcessCancelledEventImpl(org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl) Deployment(org.activiti.engine.test.Deployment)

Example 2 with ActivitiProcessCancelledEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl in project Activiti by Activiti.

the class ProcessInstanceEventsTest method testProcessInstanceTerminatedEvents_callActivity.

@Deployment(resources = { "org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInCallActivity.bpmn", "org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.subProcessTerminate.bpmn" })
public void testProcessInstanceTerminatedEvents_callActivity() throws Exception {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample");
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preNormalEnd").singleResult();
    taskService.complete(task.getId());
    assertProcessEnded(pi.getId());
    List<ActivitiEvent> processTerminatedEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
    assertThat(processTerminatedEvents).as("There should be exactly one ActivitiEventType.PROCESS_CANCELLED event after the task complete.").hasSize(1);
    ActivitiProcessCancelledEventImpl processCancelledEvent = (ActivitiProcessCancelledEventImpl) processTerminatedEvents.get(0);
    assertThat(processCancelledEvent.getProcessInstanceId()).isNotEqualTo(pi.getProcessInstanceId());
    assertThat(processCancelledEvent.getProcessDefinitionId()).contains("terminateEndEventSubprocessExample");
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) ActivitiProcessCancelledEventImpl(org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ActivitiProcessCancelledEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl 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();
    assertThat(executionEntities).isEqualTo(3);
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).taskDefinitionKey("preTerminateTask").singleResult();
    taskService.complete(task.getId());
    List<ActivitiEvent> processTerminatedEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
    assertThat(processTerminatedEvents).as("There should be exactly one ActivitiEventType.PROCESS_CANCELLED event after the task complete.").hasSize(1);
    ActivitiProcessCancelledEventImpl activitiEvent = (ActivitiProcessCancelledEventImpl) processTerminatedEvents.get(0);
    assertThat(activitiEvent.getProcessInstanceId()).isEqualTo(pi.getProcessInstanceId());
    List<ActivitiEvent> activityTerminatedEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(activityTerminatedEvents).as("There should be exactly two ActivitiEventType.ACTIVITY_CANCELLED event after the task complete.").hasSize(2);
    for (ActivitiEvent event : activityTerminatedEvents) {
        ActivitiActivityCancelledEventImpl activityEvent = (ActivitiActivityCancelledEventImpl) event;
        if (activityEvent.getActivityId().equals("preNormalTerminateTask")) {
            assertThat(activityEvent.getActivityId()).as("The user task must be terminated").isEqualTo("preNormalTerminateTask");
            assertThat(activityEvent.getCause()).as("The cause must be terminate end event").isEqualTo("Terminated by end event: EndEvent_2");
        } else if (activityEvent.getActivityId().equals("EndEvent_2")) {
            assertThat(activityEvent.getActivityId()).as("The end event must be terminated").isEqualTo("EndEvent_2");
            assertThat(activityEvent.getCause()).as("The cause must be terminate end event").isEqualTo("Terminated by end event: EndEvent_2");
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) ActivitiActivityCancelledEventImpl(org.activiti.engine.delegate.event.impl.ActivitiActivityCancelledEventImpl) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) ActivitiProcessCancelledEventImpl(org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ActivitiEvent (org.activiti.engine.delegate.event.ActivitiEvent)3 ActivitiProcessCancelledEventImpl (org.activiti.engine.delegate.event.impl.ActivitiProcessCancelledEventImpl)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 Task (org.activiti.engine.task.Task)3 Deployment (org.activiti.engine.test.Deployment)3 ActivitiActivityCancelledEventImpl (org.activiti.engine.delegate.event.impl.ActivitiActivityCancelledEventImpl)2