Search in sources :

Example 11 with RecordedEvent

use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent 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)

Example 12 with RecordedEvent

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

the class ProcessInstanceModificationTest method testActivityExecutionListenerInvocation.

@Deployment(resources = SUBPROCESS_LISTENER_PROCESS)
public void testActivityExecutionListenerInvocation() {
    RecorderExecutionListener.clear();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess", Collections.<String, Object>singletonMap("listener", new RecorderExecutionListener()));
    String processInstanceId = processInstance.getId();
    assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty());
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").execute();
    // assert activity instance tree
    ActivityInstance activityInstanceTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(activityInstanceTree);
    assertEquals(processInstanceId, activityInstanceTree.getProcessInstanceId());
    assertThat(activityInstanceTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").beginScope("subProcess").activity("innerTask").done());
    // assert listener invocations
    List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
    assertEquals(2, recordedEvents.size());
    ActivityInstance subprocessInstance = getChildInstanceForActivity(activityInstanceTree, "subProcess");
    ActivityInstance innerTaskInstance = getChildInstanceForActivity(subprocessInstance, "innerTask");
    RecordedEvent firstEvent = recordedEvents.get(0);
    RecordedEvent secondEvent = recordedEvents.get(1);
    assertEquals("subProcess", firstEvent.getActivityId());
    assertEquals(subprocessInstance.getId(), firstEvent.getActivityInstanceId());
    assertEquals(ExecutionListener.EVENTNAME_START, secondEvent.getEventName());
    assertEquals("innerTask", secondEvent.getActivityId());
    assertEquals(innerTaskInstance.getId(), secondEvent.getActivityInstanceId());
    assertEquals(ExecutionListener.EVENTNAME_START, secondEvent.getEventName());
    RecorderExecutionListener.clear();
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(innerTaskInstance.getId()).execute();
    assertEquals(2, RecorderExecutionListener.getRecordedEvents().size());
}
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) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with RecordedEvent

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

the class ProcessInstanceModificationTest method testStartTransitionListenerInvocation.

@Deployment(resources = TRANSITION_LISTENER_PROCESS)
public void testStartTransitionListenerInvocation() {
    RecorderExecutionListener.clear();
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    runtimeService.createProcessInstanceModification(instance.getId()).startTransition("flow2").execute();
    // transition listener should have been invoked
    List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
    assertEquals(1, events.size());
    RecordedEvent event = events.get(0);
    assertEquals("flow2", event.getTransitionId());
    RecorderExecutionListener.clear();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.getId());
    assertNotNull(updatedTree);
    assertEquals(instance.getId(), updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());
    completeTasksInOrder("task1", "task2", "task2");
    assertProcessEnded(instance.getId());
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) 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 14 with RecordedEvent

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

the class ProcessInstanceModificationTest method testStartAfterActivityListenerInvocation.

@Deployment(resources = TRANSITION_LISTENER_PROCESS)
public void testStartAfterActivityListenerInvocation() {
    RecorderExecutionListener.clear();
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    runtimeService.createProcessInstanceModification(instance.getId()).startTransition("flow2").execute();
    // transition listener should have been invoked
    List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
    assertEquals(1, events.size());
    RecordedEvent event = events.get(0);
    assertEquals("flow2", event.getTransitionId());
    RecorderExecutionListener.clear();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.getId());
    assertNotNull(updatedTree);
    assertEquals(instance.getId(), updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done());
    completeTasksInOrder("task1", "task2", "task2");
    assertProcessEnded(instance.getId());
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) 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 15 with RecordedEvent

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

the class ProcessInstanceModificationAsyncTest method testCancelAsyncAfterTransitionInstanceInvokesParentListeners.

@Deployment
public void testCancelAsyncAfterTransitionInstanceInvokesParentListeners() {
    RecorderExecutionListener.clear();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener()));
    String processInstanceId = processInstance.getId();
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstanceId).cancelTransitionInstance(getChildTransitionInstanceForTargetActivity(tree, "subProcessEnd").getId()).execute();
    assertEquals(1, RecorderExecutionListener.getRecordedEvents().size());
    RecordedEvent event = RecorderExecutionListener.getRecordedEvents().get(0);
    assertEquals("subProcess", event.getActivityId());
    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)

Aggregations

RecordedEvent (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent)17 Deployment (org.camunda.bpm.engine.test.Deployment)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)13 Test (org.junit.Test)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)7 RecorderExecutionListener (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener)6 Task (org.camunda.bpm.engine.task.Task)4 Job (org.camunda.bpm.engine.runtime.Job)2 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)2 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)2 HashSet (java.util.HashSet)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1