use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOn_SubProcess_Boundary_Event.
@Test
public void processWithParallelMultiInstancesOn_SubProcess_Boundary_Event() {
// when
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelSubProcessBoundaryEvent");
// then
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("Task in sub-process 0", "Task in sub-process 1");
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
assertThat(localEventSource.getTaskEvents()).extracting(event -> ((Task) event.getEntity()).getName(), RuntimeEvent::getEventType).containsExactlyInAnyOrder(tuple("Task in sub-process 0", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("Task in sub-process 1", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("Task in sub-process 0", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED), tuple("Task in sub-process 1", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED));
// send signal: boundary event should cancel multi-instance
localEventSource.clearEvents();
processBaseRuntime.signal("goMiParallelSubProcessBoundaryEvent");
assertThat(localEventSource.getTaskEvents()).extracting(event -> ((Task) event.getEntity()).getName(), RuntimeEvent::getEventType).containsExactlyInAnyOrder(tuple("Task in sub-process 0", TaskRuntimeEvent.TaskEvents.TASK_CANCELLED), tuple("Task in sub-process 1", TaskRuntimeEvent.TaskEvents.TASK_CANCELLED), tuple("Escalation Task", TaskRuntimeEvent.TaskEvents.TASK_CREATED), tuple("Escalation Task", TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED));
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED);
tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks.size()).isEqualTo(1);
assertThat(tasks).extracting(Task::getName).contains("Escalation Task");
taskBaseRuntime.completeTask(tasks.get(0));
assertThat(taskBaseRuntime.getTasks(processInstance)).isEmpty();
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOnUserTask_should_emmit_EqualStartAndEndEvent.
@Test
public void processWithParallelMultiInstancesOnUserTask_should_emmit_EqualStartAndEndEvent() {
// when
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelUserTasks");
// then
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("My Task 0", "My Task 1");
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()));
assertActivityEvents("miTasks", 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, "My Task 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "My Task 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "My Task 1", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "My Task 1", processInstance.getId()));
// complete first iteration: multi instance should not complete yet
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertActivityEvents("miTasks", 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, tasks.get(0).getName(), processInstance.getId()));
assertThat(localEventSource.getProcessInstanceEvents()).isEmpty();
// complete second iteration: multi instance should complete
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(1));
assertActivityEvents("miTasks", 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, tasks.get(1).getName(), processInstance.getId()));
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, event -> ((ProcessInstance) event.getEntity()).getId()).containsExactlyInAnyOrder(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
assertThat(taskBaseRuntime.getTasks(processInstance)).isEmpty();
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithSequentialMultiInstancesOnUserTask_should_emmit_EqualStartAndEndEvent.
@Test
public void processWithSequentialMultiInstancesOnUserTask_should_emmit_EqualStartAndEndEvent() {
// when
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miSequentialUserTasks");
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()));
assertActivityEvents("miTasks", 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, "My Task 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "My Task 0", processInstance.getId()));
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("My Task 0");
// complete first iteration, multi-instance should not complete yet
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertActivityEvents("miTasks", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, // second iteration was created
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_COMPLETED, "My Task 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "My Task 1", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "My Task 1", processInstance.getId()));
tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("My Task 1");
// complete second iteration, multi-instance should not complete
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertActivityEvents("miTasks", 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, "My Task 1", processInstance.getId()));
assertThat(taskBaseRuntime.getTasks(processInstance)).isEmpty();
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).contains(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithSequentialMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent.
@Test
public void processWithSequentialMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent() {
// when
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miSequentialSubprocess");
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()));
assertActivityEvents("miSubProcess", 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, "Task in sub-process 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "Task in sub-process 0", processInstance.getId()));
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("Task in sub-process 0");
// complete first iteration, multi-instance should not complete yet
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, // second iteration was created
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_COMPLETED, "Task in sub-process 0", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "Task in sub-process 1", processInstance.getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "Task in sub-process 1", processInstance.getId()));
tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("Task in sub-process 1");
// complete second iteration, multi-instance should not complete
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertActivityEvents("miSubProcess", 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, "Task in sub-process 1", processInstance.getId()));
assertThat(taskBaseRuntime.getTasks(processInstance)).isEmpty();
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOnCallActivity_should_emmit_EqualStartAndEndEvent.
@Test
public void processWithParallelMultiInstancesOnCallActivity_should_emmit_EqualStartAndEndEvent() {
ProcessInstance parentProcessInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelCallActivity");
List<ProcessInstance> childrenProcess = processBaseRuntime.getChildrenProcessInstances(parentProcessInstance.getId()).getContent();
assertThat(childrenProcess).hasSize(2);
assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
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, childrenProcess.get(0).getId(), parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, childrenProcess.get(1).getId(), parentProcessInstance.getId()));
assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcess.get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_CREATED, "User Task", childrenProcess.get(1).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcess.get(0).getId()), tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, "User Task", childrenProcess.get(1).getId()));
// complete first iteration: multi instance should not complete yet
List<TaskAssignedEvent> taskAssignedEvents = localEventSource.getEvents(TaskAssignedEvent.class);
localEventSource.clearEvents();
TaskAssignedEvent taskAssignedEvent = taskAssignedEvents.get(0);
taskBaseRuntime.completeTask(taskAssignedEvent.getEntity());
assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, "User Task", taskAssignedEvent.getEntity().getProcessInstanceId()));
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId, event -> ((ProcessInstance) event.getEntity()).getParentId()).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, taskAssignedEvent.getEntity().getProcessInstanceId(), parentProcessInstance.getId()));
// complete second iteration: multi instance should complete
localEventSource.clearEvents();
taskAssignedEvent = taskAssignedEvents.get(1);
taskBaseRuntime.completeTask(taskAssignedEvent.getEntity());
assertActivityEvents("miCallActivity", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactlyInAnyOrder(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, "User Task", taskAssignedEvent.getEntity().getProcessInstanceId()));
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId, event -> ((ProcessInstance) event.getEntity()).getParentId()).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, taskAssignedEvent.getEntity().getProcessInstanceId(), parentProcessInstance.getId()), tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, parentProcessInstance.getId(), null));
assertThat(processBaseRuntime.getProcessInstances()).isEmpty();
}
Aggregations