use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesTest method testSkipListenerInvocation.
@Deployment(resources = LISTENERS_PROCESS)
public void testSkipListenerInvocation() {
RecorderExecutionListener.clear();
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("listenerProcess").startBeforeActivity("innerTask").execute(true, true);
// 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(0, events.size());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesTest method testStartMultipleTasksInSyncProcess.
@Deployment(resources = SYNC_PROCESS)
public void testStartMultipleTasksInSyncProcess() {
RecorderExecutionListener.clear();
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("syncProcess").startBeforeActivity("syncTask").startBeforeActivity("syncTask").startBeforeActivity("syncTask").execute();
// then the request was successful even though the process instance has already ended
assertNotNull(instance);
assertProcessEnded(instance.getId());
// and the execution listener was invoked correctly
List<RecordedEvent> events = RecorderExecutionListener.getRecordedEvents();
assertEquals(8, events.size());
// process start event
assertEquals(ExecutionListener.EVENTNAME_START, events.get(0).getEventName());
assertEquals("syncTask", events.get(0).getActivityId());
// start instruction 1
assertEquals(ExecutionListener.EVENTNAME_START, events.get(1).getEventName());
assertEquals("syncTask", events.get(1).getActivityId());
assertEquals(ExecutionListener.EVENTNAME_END, events.get(2).getEventName());
assertEquals("syncTask", events.get(2).getActivityId());
// start instruction 2
assertEquals(ExecutionListener.EVENTNAME_START, events.get(3).getEventName());
assertEquals("syncTask", events.get(3).getActivityId());
assertEquals(ExecutionListener.EVENTNAME_END, events.get(4).getEventName());
assertEquals("syncTask", events.get(4).getActivityId());
// start instruction 3
assertEquals(ExecutionListener.EVENTNAME_START, events.get(5).getEventName());
assertEquals("syncTask", events.get(5).getActivityId());
assertEquals(ExecutionListener.EVENTNAME_END, events.get(6).getEventName());
assertEquals("syncTask", events.get(6).getActivityId());
// process end event
assertEquals(ExecutionListener.EVENTNAME_END, events.get(7).getEventName());
assertEquals("end", events.get(7).getActivityId());
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent 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();
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent in project camunda-bpm-platform by camunda.
the class ExecutionListenerTest method testExecutionListenersOnStartEndEvents.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/executionlistener/ExecutionListenersStartEndEvent.bpmn20.xml" })
public void testExecutionListenersOnStartEndEvents() {
RecorderExecutionListener.clear();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenersProcess");
assertProcessEnded(processInstance.getId());
List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
assertEquals(4, recordedEvents.size());
assertEquals("theStart", recordedEvents.get(0).getActivityId());
assertEquals("Start Event", recordedEvents.get(0).getActivityName());
assertEquals("Start Event Listener", recordedEvents.get(0).getParameter());
assertEquals("end", recordedEvents.get(0).getEventName());
assertThat(recordedEvents.get(0).isCanceled(), is(false));
assertEquals("noneEvent", recordedEvents.get(1).getActivityId());
assertEquals("None Event", recordedEvents.get(1).getActivityName());
assertEquals("Intermediate Catch Event Listener", recordedEvents.get(1).getParameter());
assertEquals("end", recordedEvents.get(1).getEventName());
assertThat(recordedEvents.get(1).isCanceled(), is(false));
assertEquals("signalEvent", recordedEvents.get(2).getActivityId());
assertEquals("Signal Event", recordedEvents.get(2).getActivityName());
assertEquals("Intermediate Throw Event Listener", recordedEvents.get(2).getParameter());
assertEquals("start", recordedEvents.get(2).getEventName());
assertThat(recordedEvents.get(2).isCanceled(), is(false));
assertEquals("theEnd", recordedEvents.get(3).getActivityId());
assertEquals("End Event", recordedEvents.get(3).getActivityName());
assertEquals("End Event Listener", recordedEvents.get(3).getParameter());
assertEquals("start", recordedEvents.get(3).getEventName());
assertThat(recordedEvents.get(3).isCanceled(), is(false));
}
use of org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent in project camunda-bpm-platform by camunda.
the class ExecutionListenerTest method testOnCancellingBoundaryEvents.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/executionlistener/ExecutionListenerTest.testOnCancellingBoundaryEvent.bpmn" })
public void testOnCancellingBoundaryEvents() {
RecorderExecutionListener.clear();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
Job timer = managementService.createJobQuery().timers().singleResult();
managementService.executeJob(timer.getId());
assertProcessEnded(processInstance.getId());
List<RecordedEvent> recordedEvents = RecorderExecutionListener.getRecordedEvents();
assertThat(recordedEvents, hasSize(1));
assertEquals("UserTask_1", recordedEvents.get(0).getActivityId());
assertEquals("end", recordedEvents.get(0).getEventName());
assertThat(recordedEvents.get(0).isCanceled(), is(true));
}
Aggregations