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