Search in sources :

Example 1 with BPMNActivityCancelledEvent

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()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) DummyBPMNTimerCancelledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerCancelledListener) ProcessRuntimeEvent(org.activiti.api.process.model.events.ProcessRuntimeEvent) Task(org.activiti.api.task.model.Task) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BPMNActivityStartedEvent(org.activiti.api.process.model.events.BPMNActivityStartedEvent) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) ProcessStartedEvent(org.activiti.api.process.runtime.events.ProcessStartedEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessCompletedEvent(org.activiti.api.process.runtime.events.ProcessCompletedEvent) ActiveProfiles(org.springframework.test.context.ActiveProfiles) DummyBPMNTimerScheduledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerScheduledListener) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) BPMNTimerEvent(org.activiti.api.process.model.events.BPMNTimerEvent) TaskCreatedEvent(org.activiti.api.task.runtime.events.TaskCreatedEvent) Arrays.asList(java.util.Arrays.asList) DummyBPMNTimerExecutedListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerExecutedListener) LocalEventSource(org.activiti.test.LocalEventSource) Collections.singletonMap(java.util.Collections.singletonMap) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) BPMNActivityCancelledEvent(org.activiti.api.process.model.events.BPMNActivityCancelledEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) BPMNActivityCompletedEvent(org.activiti.api.process.model.events.BPMNActivityCompletedEvent) Awaitility.await(org.awaitility.Awaitility.await) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TimerTestConfigurator(org.activiti.spring.boot.process.TimerTestConfigurator) RuntimeEvent(org.activiti.api.model.shared.event.RuntimeEvent) BPMNActivityEvent(org.activiti.api.process.model.events.BPMNActivityEvent) Import(org.springframework.context.annotation.Import) Page(org.activiti.api.runtime.shared.query.Page) Collectors(java.util.stream.Collectors) TaskAssignedEvent(org.activiti.api.task.runtime.events.TaskAssignedEvent) DummyBPMNTimerFiredListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerFiredListener) Test(org.junit.jupiter.api.Test) ProcessRuntimeBPMNTimerIT(org.activiti.spring.boot.process.ProcessRuntimeBPMNTimerIT) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) ProcessBaseRuntime(org.activiti.spring.boot.process.ProcessBaseRuntime) BPMNActivityCompletedEvent(org.activiti.api.process.model.events.BPMNActivityCompletedEvent) BPMNActivityStartedEvent(org.activiti.api.process.model.events.BPMNActivityStartedEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) BPMNActivityCancelledEvent(org.activiti.api.process.model.events.BPMNActivityCancelledEvent)

Aggregations

Arrays.asList (java.util.Arrays.asList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 RuntimeEvent (org.activiti.api.model.shared.event.RuntimeEvent)1 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)1 ProcessInstance (org.activiti.api.process.model.ProcessInstance)1 BPMNActivityCancelledEvent (org.activiti.api.process.model.events.BPMNActivityCancelledEvent)1 BPMNActivityCompletedEvent (org.activiti.api.process.model.events.BPMNActivityCompletedEvent)1 BPMNActivityEvent (org.activiti.api.process.model.events.BPMNActivityEvent)1 BPMNActivityStartedEvent (org.activiti.api.process.model.events.BPMNActivityStartedEvent)1 BPMNTimerEvent (org.activiti.api.process.model.events.BPMNTimerEvent)1 ProcessRuntimeEvent (org.activiti.api.process.model.events.ProcessRuntimeEvent)1 ProcessCompletedEvent (org.activiti.api.process.runtime.events.ProcessCompletedEvent)1 ProcessStartedEvent (org.activiti.api.process.runtime.events.ProcessStartedEvent)1 Page (org.activiti.api.runtime.shared.query.Page)1 Task (org.activiti.api.task.model.Task)1 TaskRuntimeEvent (org.activiti.api.task.model.events.TaskRuntimeEvent)1 TaskAssignedEvent (org.activiti.api.task.runtime.events.TaskAssignedEvent)1