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());
}
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())));
}
}
Aggregations