Search in sources :

Example 11 with RuntimeEvent

use of org.activiti.api.model.shared.event.RuntimeEvent in project Activiti by Activiti.

the class SignalThrowCatchTest method testProcessWithThrowSignal.

@Test
public void testProcessWithThrowSignal() {
    securityUtil.logInAs("user1");
    ProcessInstance processInstance = startThrowSignalProcess();
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
    assertThat(RuntimeTestConfiguration.collectedEvents).filteredOn(event -> event.getEventType().equals(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED)).filteredOn(event -> ((BPMNActivity) event.getEntity()).getActivityType().equals("throwEvent")).extracting(event -> ((BPMNActivity) event.getEntity()).getActivityType(), event -> ((BPMNActivity) event.getEntity()).getProcessInstanceId()).contains(tuple("throwEvent", processInstance.getId()));
}
Also used : VariableEvent(org.activiti.api.model.shared.event.VariableEvent) BPMNSequenceFlowTakenEvent(org.activiti.api.process.model.events.BPMNSequenceFlowTakenEvent) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) ProcessRuntimeEvent(org.activiti.api.process.model.events.ProcessRuntimeEvent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) RuntimeTestConfiguration(org.activiti.spring.conformance.util.RuntimeTestConfiguration) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) SecurityUtil(org.activiti.spring.conformance.util.security.SecurityUtil) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Assertions.tuple(org.assertj.core.api.Assertions.tuple) RuntimeEvent(org.activiti.api.model.shared.event.RuntimeEvent) BPMNActivityEvent(org.activiti.api.process.model.events.BPMNActivityEvent) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) Page(org.activiti.api.runtime.shared.query.Page) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) Test(org.junit.jupiter.api.Test) BPMNSignalEvent(org.activiti.api.process.model.events.BPMNSignalEvent) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) BPMNActivity(org.activiti.api.process.model.BPMNActivity) ProcessAdminRuntime(org.activiti.api.process.runtime.ProcessAdminRuntime) BPMNActivity(org.activiti.api.process.model.BPMNActivity) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with RuntimeEvent

use of org.activiti.api.model.shared.event.RuntimeEvent in project Activiti by Activiti.

the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent.

@Test
public void processWithParallelMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent() {
    // when
    ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelSubprocess");
    // then
    List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
    assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("Task in sub-process 0", "Task in sub-process 1");
    assertThat(localEventSource.getEvents(TaskCreatedEvent.class)).extracting(event -> event.getEntity().getName()).containsExactlyInAnyOrder("Task in sub-process 0", "Task in sub-process 1");
    assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    // complete first iteration: multi instance should not finish yet
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(0));
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, tasks.get(0).getName(), processInstance.getId()));
    assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
    assertThat(localEventSource.getProcessInstanceEvents()).isEmpty();
    // complete second iteration: multi instance should finish
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(1));
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, tasks.get(1).getName(), processInstance.getId()));
    assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(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) Task(org.activiti.api.task.model.Task) ProcessInstance(org.activiti.api.process.model.ProcessInstance) TaskCreatedEvent(org.activiti.api.task.runtime.events.TaskCreatedEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with RuntimeEvent

use of org.activiti.api.model.shared.event.RuntimeEvent in project Activiti by Activiti.

the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOn_CallActivity_Boundary_Event.

@Test
public void processWithParallelMultiInstancesOn_CallActivity_Boundary_Event() {
    ProcessInstance parentProcessInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelCallActivityBoundaryEvent");
    final Page<ProcessInstance> childrenProcessInstances = processBaseRuntime.getChildrenProcessInstances(parentProcessInstance.getId());
    assertThat(childrenProcessInstances.getContent()).hasSize(2);
    assertThat(localEventSource.getEvents(ProcessStartedEvent.class)).extracting(RuntimeEvent::getEventType, event -> event.getEntity().getId(), event -> event.getEntity().getParentId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, parentProcessInstance.getId(), null), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, childrenProcessInstances.getContent().get(0).getId(), parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, childrenProcessInstances.getContent().get(1).getId(), parentProcessInstance.getId()));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcessInstances.getContent().get(1).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcessInstances.getContent().get(1).getId()));
    assertThat(localEventSource.getEvents(ProcessCompletedEvent.class)).isEmpty();
    // when
    localEventSource.clearEvents();
    processBaseRuntime.signal("goMiParallelCallActivityBoundaryEvent");
    // then
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, "User Task", childrenProcessInstances.getContent().get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, "User Task", childrenProcessInstances.getContent().get(1).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "Escalation Task", parentProcessInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "Escalation Task", parentProcessInstance.getId()));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED);
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED, childrenProcessInstances.getContent().get(0).getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED, childrenProcessInstances.getContent().get(1).getId()));
    List<Task> tasks = taskBaseRuntime.getTasks(parentProcessInstance);
    assertThat(tasks.size()).isEqualTo(1);
    assertThat(tasks).extracting(Task::getName).contains("Escalation Task");
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(0));
    assertThat(taskBaseRuntime.getTasks(parentProcessInstance)).isEmpty();
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, parentProcessInstance.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) Task(org.activiti.api.task.model.Task) ProcessStartedEvent(org.activiti.api.process.runtime.events.ProcessStartedEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with RuntimeEvent

use of org.activiti.api.model.shared.event.RuntimeEvent in project Activiti by Activiti.

the class TaskRuntimeMultiInstanceIT method processWithSequentialMultiInstancesOnCallActivity_should_emmit_EqualStartAndEndEvent.

@Test
public void processWithSequentialMultiInstancesOnCallActivity_should_emmit_EqualStartAndEndEvent() {
    ProcessInstance parentProcessInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miSequentialCallActivity");
    List<ProcessInstance> childrenProcessInstances = processBaseRuntime.getChildrenProcessInstances(parentProcessInstance.getId()).getContent();
    assertThat(childrenProcessInstances).hasSize(1);
    ProcessInstance firstChildProcInst = childrenProcessInstances.get(0);
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, firstChildProcInst.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, firstChildProcInst.getId()));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", firstChildProcInst.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", firstChildProcInst.getId()));
    List<Task> tasks = taskBaseRuntime.getTasks(firstChildProcInst);
    assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("User Task");
    // complete first iteration, multi-instance should not complete yet
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(0));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, // second iteration was created
    BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    childrenProcessInstances = processBaseRuntime.getChildrenProcessInstances(parentProcessInstance.getId()).getContent();
    assertThat(childrenProcessInstances).hasSize(1);
    ProcessInstance secondChildProcInst = childrenProcessInstances.get(0);
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, "User Task", firstChildProcInst.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", secondChildProcInst.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", secondChildProcInst.getId()));
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).contains(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, firstChildProcInst.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, secondChildProcInst.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, secondChildProcInst.getId()));
    tasks = taskBaseRuntime.getTasks(secondChildProcInst);
    assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("User Task");
    // complete second iteration, multi-instance should not complete
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(tasks.get(0));
    assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
    assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, "User Task", secondChildProcInst.getId()));
    assertThat(processBaseRuntime.getProcessInstances()).isEmpty();
    assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).contains(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, secondChildProcInst.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, parentProcessInstance.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) Task(org.activiti.api.task.model.Task) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with RuntimeEvent

use of org.activiti.api.model.shared.event.RuntimeEvent in project Activiti by Activiti.

the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOnUserTask_should_emmitEventsAndContinueOnceCompletionConditionIsReached.

@Test
public void processWithParallelMultiInstancesOnUserTask_should_emmitEventsAndContinueOnceCompletionConditionIsReached() {
    // when
    ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelUserTasksCompletionCondition");
    // then
    List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
    assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("My Task 0", "My Task 1", "My Task 2", "My Task 3");
    assertThat(localEventSource.getTaskEvents()).extracting(event -> ((Task) event.getEntity()).getName(), RuntimeEvent::getEventType).containsExactlyInAnyOrder(tuple("My Task 0", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("My Task 1", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("My Task 2", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("My Task 3", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("My Task 0", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED), tuple("My Task 1", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED), tuple("My Task 2", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED), tuple("My Task 3", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED));
    assertActivityEvents("miTasks", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    // given
    Task taskToComplete = tasks.get(0);
    // when first multi instance is completed: 3 remaining / completion condition not reached
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(taskToComplete);
    // then
    assertThat(localEventSource.getTaskEvents()).extracting(event -> ((Task) event.getEntity()).getName(), RuntimeEvent::getEventType).containsExactly(tuple(taskToComplete.getName(), TaskRuntimeEvent.TaskEvents.TASK_COMPLETED));
    assertActivityEvents("miTasks", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
    // given
    taskToComplete = tasks.get(1);
    // when second multi instance is completed: 2 remaining / completion condition reached
    localEventSource.clearEvents();
    taskBaseRuntime.completeTask(taskToComplete);
    assertThat(localEventSource.getTaskEvents()).extracting(event -> ((Task) event.getEntity()).getName(), RuntimeEvent::getEventType).containsExactlyInAnyOrder(tuple(taskToComplete.getName(), TaskRuntimeEvent.TaskEvents.TASK_COMPLETED), tuple(tasks.get(2).getName(), TaskRuntimeEvent.TaskEvents.TASK_CANCELLED), tuple(tasks.get(3).getName(), TaskRuntimeEvent.TaskEvents.TASK_CANCELLED));
    assertActivityEvents("miTasks", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED);
    assertThat(taskBaseRuntime.getTasks(processInstance)).isEmpty();
    assertThat(localEventSource.getEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).contains(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) Task(org.activiti.api.task.model.Task) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

RuntimeEvent (org.activiti.api.model.shared.event.RuntimeEvent)16 ProcessInstance (org.activiti.api.process.model.ProcessInstance)16 ProcessRuntimeEvent (org.activiti.api.process.model.events.ProcessRuntimeEvent)16 Page (org.activiti.api.runtime.shared.query.Page)16 TaskRuntimeEvent (org.activiti.api.task.model.events.TaskRuntimeEvent)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 Assertions.tuple (org.assertj.core.api.Assertions.tuple)16 AfterEach (org.junit.jupiter.api.AfterEach)16 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Test (org.junit.jupiter.api.Test)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 Collections.singletonMap (java.util.Collections.singletonMap)15 List (java.util.List)15 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)15 Task (org.activiti.api.task.model.Task)15 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)15 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)15 LocalEventSource (org.activiti.test.LocalEventSource)15 BPMNActivityEvent (org.activiti.api.process.model.events.BPMNActivityEvent)14