Search in sources :

Example 1 with ActivitiActivityCancelledEvent

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

the class ProcessInstanceEventsTest method testProcessInstanceCancelledEvents_cancell.

@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceCancelledEvents_cancell() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    assertNotNull(processInstance);
    listener.clearEventsReceived();
    runtimeService.deleteProcessInstance(processInstance.getId(), "delete_test");
    List<ActivitiEvent> processCancelledEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
    assertEquals("ActivitiEventType.PROCESS_CANCELLED was expected 1 time.", 1, processCancelledEvents.size());
    ActivitiCancelledEvent processCancelledEvent = (ActivitiCancelledEvent) processCancelledEvents.get(0);
    assertTrue("The cause has to be the same as deleteProcessInstance method call", ActivitiCancelledEvent.class.isAssignableFrom(processCancelledEvent.getClass()));
    assertEquals("The process instance has to be the same as in deleteProcessInstance method call", processInstance.getId(), processCancelledEvent.getProcessInstanceId());
    assertEquals("The execution instance has to be the same as in deleteProcessInstance method call", processInstance.getId(), processCancelledEvent.getExecutionId());
    assertEquals("The cause has to be the same as in deleteProcessInstance method call", "delete_test", processCancelledEvent.getCause());
    List<ActivitiEvent> taskCancelledEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
    assertEquals("ActivitiEventType.ACTIVITY_CANCELLED was expected 1 time.", 1, taskCancelledEvents.size());
    ActivitiActivityCancelledEvent activityCancelledEvent = (ActivitiActivityCancelledEvent) taskCancelledEvents.get(0);
    assertTrue("The cause has to be the same as deleteProcessInstance method call", ActivitiActivityCancelledEvent.class.isAssignableFrom(activityCancelledEvent.getClass()));
    assertEquals("The activity id has to be the same as processInstance activity", processInstance.getActivityId(), activityCancelledEvent.getActivityId());
    assertEquals("The process instance has to be the same as in deleteProcessInstance method call", processInstance.getId(), activityCancelledEvent.getProcessInstanceId());
    assertEquals("The execution instance has to be the same as in deleteProcessInstance method call", processInstance.getId(), activityCancelledEvent.getExecutionId());
    assertEquals("The cause has to be the same as in deleteProcessInstance method call", "delete_test", activityCancelledEvent.getCause());
    listener.clearEventsReceived();
}
Also used : ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ActivitiCancelledEvent(org.activiti.engine.delegate.event.ActivitiCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) Deployment(org.activiti.engine.test.Deployment)

Example 2 with ActivitiActivityCancelledEvent

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

the class ProcessInstanceEventsTest method testProcessInstanceCancelledEvents_cancel.

@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceCancelledEvents_cancel() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    assertThat(processInstance).isNotNull();
    listener.clearEventsReceived();
    runtimeService.deleteProcessInstance(processInstance.getId(), "delete_test");
    List<ActivitiEvent> processCancelledEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
    assertThat(processCancelledEvents).as("ActivitiEventType.PROCESS_CANCELLED was expected 1 time.").hasSize(1);
    ActivitiCancelledEvent processCancelledEvent = (ActivitiCancelledEvent) processCancelledEvents.get(0);
    assertThat(ActivitiCancelledEvent.class.isAssignableFrom(processCancelledEvent.getClass())).as("The cause has to be the same as deleteProcessInstance method call").isTrue();
    assertThat(processCancelledEvent.getProcessInstanceId()).as("The process instance has to be the same as in deleteProcessInstance method call").isEqualTo(processInstance.getId());
    assertThat(processCancelledEvent.getExecutionId()).as("The execution instance has to be the same as in deleteProcessInstance method call").isEqualTo(processInstance.getId());
    assertThat(processCancelledEvent.getCause()).as("The cause has to be the same as in deleteProcessInstance method call").isEqualTo("delete_test");
    List<ActivitiEvent> taskCancelledEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(taskCancelledEvents).as("ActivitiEventType.ACTIVITY_CANCELLED was expected 1 time.").hasSize(1);
    ActivitiActivityCancelledEvent activityCancelledEvent = (ActivitiActivityCancelledEvent) taskCancelledEvents.get(0);
    assertThat(ActivitiActivityCancelledEvent.class.isAssignableFrom(activityCancelledEvent.getClass())).as("The cause has to be the same as deleteProcessInstance method call").isTrue();
    assertThat(activityCancelledEvent.getProcessInstanceId()).as("The process instance has to be the same as in deleteProcessInstance method call").isEqualTo(processInstance.getId());
    assertThat(activityCancelledEvent.getCause()).as("The cause has to be the same as in deleteProcessInstance method call").isEqualTo("delete_test");
    listener.clearEventsReceived();
}
Also used : ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ActivitiCancelledEvent(org.activiti.engine.delegate.event.ActivitiCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ActivitiActivityCancelledEvent

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

the class ProcessInstanceEventsTest method testProcessInstanceCancelledEvents_cancelProcessHierarchy.

@Deployment(resources = { "org/activiti/engine/test/api/runtime/nestedSubProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testProcessInstanceCancelledEvents_cancelProcessHierarchy() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedSimpleSubProcess");
    ProcessInstance subProcess = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).singleResult();
    assertThat(processInstance).isNotNull();
    listener.clearEventsReceived();
    runtimeService.deleteProcessInstance(processInstance.getId(), "delete_test");
    List<ActivitiEvent> processCancelledEvents = listener.filterEvents(ActivitiEventType.PROCESS_CANCELLED);
    assertThat(processCancelledEvents).as("ActivitiEventType.PROCESS_CANCELLED was expected 2 times.").hasSize(2);
    ActivitiCancelledEvent processCancelledEvent = (ActivitiCancelledEvent) processCancelledEvents.get(0);
    assertThat(ActivitiCancelledEvent.class.isAssignableFrom(processCancelledEvent.getClass())).as("The cause has to be the same as deleteProcessInstance method call").isTrue();
    assertThat(processCancelledEvent.getProcessInstanceId()).as("The process instance has to be the same as in deleteProcessInstance method call").isEqualTo(subProcess.getId());
    assertThat(processCancelledEvent.getExecutionId()).as("The execution instance has to be the same as in deleteProcessInstance method call").isEqualTo(subProcess.getId());
    assertThat(processCancelledEvent.getCause()).as("The cause has to be the same as in deleteProcessInstance method call").isEqualTo("delete_test");
    processCancelledEvent = (ActivitiCancelledEvent) processCancelledEvents.get(1);
    assertThat(ActivitiCancelledEvent.class.isAssignableFrom(processCancelledEvent.getClass())).as("The cause has to be the same as deleteProcessInstance method call").isTrue();
    assertThat(processCancelledEvent.getProcessInstanceId()).as("The process instance has to be the same as in deleteProcessInstance method call").isEqualTo(processInstance.getId());
    assertThat(processCancelledEvent.getExecutionId()).as("The execution instance has to be the same as in deleteProcessInstance method call").isEqualTo(processInstance.getId());
    assertThat(processCancelledEvent.getCause()).as("The cause has to be the same as in deleteProcessInstance method call").isEqualTo("delete_test");
    assertThat(this.taskService.createTaskQuery().processInstanceId(processInstance.getId()).count()).as("No task can be active for deleted process.").isEqualTo(0);
    List<ActivitiEvent> taskCancelledEvents = listener.filterEvents(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(taskCancelledEvents).as("ActivitiEventType.ACTIVITY_CANCELLED was expected 1 time.").hasSize(1);
    ActivitiActivityCancelledEvent activityCancelledEvent = (ActivitiActivityCancelledEvent) taskCancelledEvents.get(0);
    assertThat(ActivitiActivityCancelledEvent.class.isAssignableFrom(activityCancelledEvent.getClass())).as("The cause has to be the same as deleteProcessInstance method call").isTrue();
    assertThat(activityCancelledEvent.getProcessInstanceId()).as("The process instance has to point to the subprocess").isEqualTo(subProcess.getId());
    assertThat(activityCancelledEvent.getCause()).as("The cause has to be the same as in deleteProcessInstance method call").isEqualTo("delete_test");
    listener.clearEventsReceived();
}
Also used : ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ActivitiCancelledEvent(org.activiti.engine.delegate.event.ActivitiCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiEvent(org.activiti.engine.delegate.event.ActivitiEvent) Deployment(org.activiti.engine.test.Deployment)

Example 4 with ActivitiActivityCancelledEvent

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

the class ActivityEventsTest method testActivityMessageBoundaryEventsOnUserTask.

/**
 * Test events related to message events, called from the API.
 */
@Deployment
public void testActivityMessageBoundaryEventsOnUserTask() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnUserTaskProcess");
    assertThat(processInstance).isNotNull();
    Execution executionWithMessage = runtimeService.createExecutionQuery().messageEventSubscriptionName("message_1").singleResult();
    assertThat(executionWithMessage).isNotNull();
    Execution taskExecution = runtimeService.createExecutionQuery().activityId("cloudformtask1").processInstanceId(processInstance.getId()).singleResult();
    assertThat(taskExecution).isNotNull();
    runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
    assertThat(listener.getEventsReceived()).hasSize(3);
    // First, an ACTIVITY_MESSAGE_WAITING event is expected
    assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiMessageEvent.class);
    ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
    assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_WAITING);
    assertThat(messageEvent.getActivityId()).isEqualTo("boundaryMessageEventCatching");
    assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
    assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
    assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(messageEvent.getMessageName()).isEqualTo("message_1");
    assertThat(messageEvent.getMessageData()).isNull();
    // Second, an ACTIVITY_MESSAGE_RECEIVED event is expected
    assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiMessageEvent.class);
    messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(1);
    assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
    assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
    assertThat(messageEvent.getActivityId()).isEqualTo("boundaryMessageEventCatching");
    assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
    assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
    assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(messageEvent.getMessageName()).isEqualTo("message_1");
    assertThat(messageEvent.getMessageData()).isNull();
    // Next, an signal-event is expected, as a result of the message
    assertThat(listener.getEventsReceived().get(2)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    ActivitiActivityCancelledEvent cancelledEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(2);
    assertThat(cancelledEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelledEvent.getActivityId()).isEqualTo("cloudformtask1");
    assertThat(cancelledEvent.getExecutionId()).isEqualTo(taskExecution.getId());
    assertThat(cancelledEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
    assertThat(cancelledEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelledEvent.getCause()).isEqualTo("boundary event (boundaryMessageEventCatching)");
    assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
Also used : Execution(org.activiti.engine.runtime.Execution) ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Deployment(org.activiti.engine.test.Deployment)

Example 5 with ActivitiActivityCancelledEvent

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

the class ActivityEventsTest method testActivitySignalBoundaryEventsOnSubProcess.

@Deployment
public void testActivitySignalBoundaryEventsOnSubProcess() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalOnSubProcess");
    assertThat(processInstance).isNotNull();
    Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("userTaskInsideProcess").singleResult();
    assertThat(executionWithSignal).isNotNull();
    runtimeService.signalEventReceived("signalName");
    assertThat(listener.getEventsReceived()).hasSize(3);
    assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiSignalEventImpl.class);
    ActivitiSignalEventImpl signalEvent = (ActivitiSignalEventImpl) listener.getEventsReceived().get(0);
    assertThat(signalEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_SIGNALED);
    assertThat(signalEvent.getActivityId()).isEqualTo("boundarySignalEventCatching");
    assertThat(signalEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(signalEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(listener.getEventsReceived().get(2)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    ActivitiActivityCancelledEvent cancelEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(2);
    assertThat(cancelEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelEvent.getActivityId()).isEqualTo("subProcess");
    assertThat(cancelEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(cancelEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelEvent.getCause()).isEqualTo("boundary event (boundarySignalEventCatching)");
    assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    cancelEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
    assertThat(cancelEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelEvent.getActivityId()).isEqualTo("userTaskInsideProcess");
    assertThat(cancelEvent.getExecutionId()).isEqualTo(executionWithSignal.getId());
    assertThat(cancelEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(cancelEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelEvent.getCause()).isEqualTo("boundary event (boundarySignalEventCatching)");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) Execution(org.activiti.engine.runtime.Execution) ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ActivitiActivityCancelledEvent (org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent)11 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)10 Deployment (org.activiti.engine.test.Deployment)10 ActivitiEvent (org.activiti.engine.delegate.event.ActivitiEvent)6 Execution (org.activiti.engine.runtime.Execution)5 Calendar (java.util.Calendar)3 ActivitiCancelledEvent (org.activiti.engine.delegate.event.ActivitiCancelledEvent)3 ActivitiMessageEvent (org.activiti.engine.delegate.event.ActivitiMessageEvent)3 ActivitiSignalEventImpl (org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl)3 Job (org.activiti.engine.runtime.Job)3 ArrayList (java.util.ArrayList)2 Task (org.activiti.engine.task.Task)2 IdmDelegationDefinitionDto (eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto)1 IdmDelegationDto (eu.bcvsolutions.idm.core.api.dto.IdmDelegationDto)1 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)1 IdmDelegationFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter)1 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)1 Collections.singletonMap (java.util.Collections.singletonMap)1 List (java.util.List)1 UUID (java.util.UUID)1