use of org.activiti.api.process.model.events.BPMNActivityCancelledEvent in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method verifyEventsOnAutomaticMultiInstanceWithCompletionCondition.
private void verifyEventsOnAutomaticMultiInstanceWithCompletionCondition(String processDefinitionKey, String elementId) {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(processDefinitionKey);
List<BPMNActivityStartedEvent> startedEvents = localEventSource.getEvents(BPMNActivityStartedEvent.class).stream().filter(event -> elementId.equals(event.getEntity().getElementId())).collect(Collectors.toList());
List<BPMNActivityCompletedEvent> completedEvents = localEventSource.getEvents(BPMNActivityCompletedEvent.class).stream().filter(event -> elementId.equals(event.getEntity().getElementId())).collect(Collectors.toList());
List<BPMNActivityCancelledEvent> cancelledEvents = localEventSource.getEvents(BPMNActivityCancelledEvent.class).stream().filter(event -> elementId.equals(event.getEntity().getElementId())).collect(Collectors.toList());
// in some cases, the execution is scheduled in the agenda but it get cancelled even before starting
assertThat(startedEvents.size()).isGreaterThanOrEqualTo(2);
assertThat(completedEvents).hasSize(2);
assertThat(cancelledEvents).hasSize(2);
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, processInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, processInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
}
Aggregations