Search in sources :

Example 1 with RecorderExecutionListener

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationTest method testSkipListenersOnSubProcessNested.

@Deployment(resources = LISTENERS_ON_SUB_PROCESS_AND_NESTED_SUB_PROCESS)
public void testSkipListenersOnSubProcessNested() {
    RecorderExecutionListener.clear();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("boundaryEvent").execute(true, false);
    assertProcessEnded(processInstance.getId());
    // then the output mapping should not have executed
    assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
}
Also used : RecorderExecutionListener(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with RecorderExecutionListener

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationAsyncTest method testCancelTransitionInstanceShouldNotInvokeIoMappingAndListenersOfTargetActivity.

@Deployment(resources = NESTED_ASYNC_BEFORE_IO_LISTENER_PROCESS)
public void testCancelTransitionInstanceShouldNotInvokeIoMappingAndListenersOfTargetActivity() {
    RecorderExecutionListener.clear();
    // given a process instance with an async task in a subprocess
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(1, managementService.createJobQuery().count());
    // when the async task is cancelled via cancelTransitionInstance
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelTransitionInstance(getChildTransitionInstanceForTargetActivity(tree, "innerTask").getId()).execute();
    // then no io mapping is executed and no end listener is executed
    assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
    assertEquals(0, runtimeService.createVariableInstanceQuery().variableName("outputMappingExecuted").count());
    // and the process can be completed successfully
    completeTasksInOrder("outerTask");
    assertProcessEnded(processInstance.getId());
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) RecorderExecutionListener(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 3 with RecorderExecutionListener

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationCancellationTest method testEndListenerInvocation.

@Deployment(resources = LISTENER_PROCESS)
public void testEndListenerInvocation() {
    RecorderExecutionListener.clear();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("listenerProcess", Collections.<String, Object>singletonMap("listener", new RecorderExecutionListener()));
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    // when one inner task is cancelled
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask1")).execute();
    assertEquals(1, RecorderExecutionListener.getRecordedEvents().size());
    RecordedEvent innerTask1EndEvent = RecorderExecutionListener.getRecordedEvents().get(0);
    assertEquals(ExecutionListener.EVENTNAME_END, innerTask1EndEvent.getEventName());
    assertEquals("innerTask1", innerTask1EndEvent.getActivityId());
    assertEquals(getInstanceIdForActivity(tree, "innerTask1"), innerTask1EndEvent.getActivityInstanceId());
    // when the second inner task is cancelled
    RecorderExecutionListener.clear();
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask2")).execute();
    assertEquals(2, RecorderExecutionListener.getRecordedEvents().size());
    RecordedEvent innerTask2EndEvent = RecorderExecutionListener.getRecordedEvents().get(0);
    assertEquals(ExecutionListener.EVENTNAME_END, innerTask2EndEvent.getEventName());
    assertEquals("innerTask2", innerTask2EndEvent.getActivityId());
    assertEquals(getInstanceIdForActivity(tree, "innerTask2"), innerTask2EndEvent.getActivityInstanceId());
    RecordedEvent subProcessEndEvent = RecorderExecutionListener.getRecordedEvents().get(1);
    assertEquals(ExecutionListener.EVENTNAME_END, subProcessEndEvent.getEventName());
    assertEquals("subProcess", subProcessEndEvent.getActivityId());
    assertEquals(getInstanceIdForActivity(tree, "subProcess"), subProcessEndEvent.getActivityInstanceId());
    // when the outer task is cancelled (and so the entire process)
    RecorderExecutionListener.clear();
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "outerTask")).execute();
    assertEquals(2, RecorderExecutionListener.getRecordedEvents().size());
    RecordedEvent outerTaskEndEvent = RecorderExecutionListener.getRecordedEvents().get(0);
    assertEquals(ExecutionListener.EVENTNAME_END, outerTaskEndEvent.getEventName());
    assertEquals("outerTask", outerTaskEndEvent.getActivityId());
    assertEquals(getInstanceIdForActivity(tree, "outerTask"), outerTaskEndEvent.getActivityInstanceId());
    RecordedEvent processEndEvent = RecorderExecutionListener.getRecordedEvents().get(1);
    assertEquals(ExecutionListener.EVENTNAME_END, processEndEvent.getEventName());
    assertNull(processEndEvent.getActivityId());
    assertEquals(tree.getId(), processEndEvent.getActivityInstanceId());
    RecorderExecutionListener.clear();
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) RecorderExecutionListener(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener) RecordedEvent(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with RecorderExecutionListener

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.

the class AsyncTaskTest method testDeleteShouldNotInvokeListeners.

/**
 * CAM-3707
 */
@Deployment
public void testDeleteShouldNotInvokeListeners() {
    RecorderExecutionListener.clear();
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncListener", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    assertEquals(1, managementService.createJobQuery().count());
    // when deleting the process instance
    runtimeService.deleteProcessInstance(instance.getId(), "");
    // then no listeners for the async activity should have been invoked because
    // it was not active yet
    assertEquals(0, RecorderExecutionListener.getRecordedEvents().size());
    RecorderExecutionListener.clear();
}
Also used : RecorderExecutionListener(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with RecorderExecutionListener

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener in project camunda-bpm-platform by camunda.

the class AsyncTaskTest method testDeleteInScopeShouldNotInvokeListeners.

/**
 * CAM-3707
 */
@Deployment
public void testDeleteInScopeShouldNotInvokeListeners() {
    RecorderExecutionListener.clear();
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("asyncListenerSubProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    assertEquals(1, managementService.createJobQuery().count());
    // when deleting the process instance
    runtimeService.deleteProcessInstance(instance.getId(), "");
    // then the async task end listener has not been executed but the listeners of the sub
    // process and the process
    List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
    assertEquals(2, recordedEvents.size());
    assertEquals("subProcess", recordedEvents.get(0).getActivityId());
    // process instance end event has no activity id
    assertNull(recordedEvents.get(1).getActivityId());
    RecorderExecutionListener.clear();
}
Also used : RecorderExecutionListener(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener) RecordedEvent(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 Deployment (org.camunda.bpm.engine.test.Deployment)10 RecorderExecutionListener (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener)10 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)7 RecordedEvent (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent)6 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)2 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2