Search in sources :

Example 16 with RecordedEvent

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

the class ProcessInstantiationAtActivitiesTest method testListenerInvocation.

@Deployment(resources = LISTENERS_PROCESS)
public void testListenerInvocation() {
    RecorderExecutionListener.clear();
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("listenerProcess").startBeforeActivity("innerTask").execute();
    // then
    ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.getId());
    assertNotNull(updatedTree);
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).beginScope("subProcess").activity("innerTask").done());
    List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
    assertEquals(3, events.size());
    RecordedEvent processStartEvent = events.get(0);
    assertEquals(ExecutionListener.EVENTNAME_START, processStartEvent.getEventName());
    assertEquals("innerTask", processStartEvent.getActivityId());
    RecordedEvent subProcessStartEvent = events.get(1);
    assertEquals(ExecutionListener.EVENTNAME_START, subProcessStartEvent.getEventName());
    assertEquals("subProcess", subProcessStartEvent.getActivityId());
    RecordedEvent innerTaskStartEvent = events.get(2);
    assertEquals(ExecutionListener.EVENTNAME_START, innerTaskStartEvent.getEventName());
    assertEquals("innerTask", innerTaskStartEvent.getActivityId());
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) 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 17 with RecordedEvent

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

the class RuntimeServiceTest method testDeleteProcessInstanceWithListeners.

@Deployment
@Test
public void testDeleteProcessInstanceWithListeners() {
    RecorderExecutionListener.clear();
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedParallelGatewayScopeTasks");
    // when
    runtimeService.deleteProcessInstance(processInstance.getId(), "");
    // then
    List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
    assertEquals(10, recordedEvents.size());
    Set<RecordedEvent> startEvents = new HashSet<RecordedEvent>();
    Set<RecordedEvent> endEvents = new HashSet<RecordedEvent>();
    for (RecordedEvent event : recordedEvents) {
        if (event.getEventName().equals(ExecutionListener.EVENTNAME_START)) {
            startEvents.add(event);
        } else if (event.getEventName().equals(ExecutionListener.EVENTNAME_END)) {
            endEvents.add(event);
        }
    }
    assertThat(startEvents, hasSize(5));
    assertThat(endEvents, hasSize(5));
    for (RecordedEvent startEvent : startEvents) {
        assertThat(startEvent.getActivityId(), is(anyOf(equalTo("innerTask1"), equalTo("innerTask2"), equalTo("outerTask"), equalTo("subProcess"), equalTo("theStart"))));
        for (RecordedEvent endEvent : endEvents) {
            if (startEvent.getActivityId().equals(endEvent.getActivityId())) {
                assertThat(startEvent.getActivityInstanceId(), is(endEvent.getActivityInstanceId()));
                assertThat(startEvent.getExecutionId(), is(endEvent.getExecutionId()));
            }
        }
    }
    for (RecordedEvent recordedEvent : endEvents) {
        assertThat(recordedEvent.getActivityId(), is(anyOf(equalTo("innerTask1"), equalTo("innerTask2"), equalTo("outerTask"), equalTo("subProcess"), nullValue())));
    }
}
Also used : RecordedEvent(org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HashSet(java.util.HashSet) Test(org.junit.Test) 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