use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method should_cancelTask_when_interruptedMessageReceived.
@Test
public void should_cancelTask_when_interruptedMessageReceived() {
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withBusinessKey("businessKey").withVariable("correlationKey", "correlationKey").withProcessDefinitionKey("messageInterruptingSubProcess").build());
List<Task> allTasks = taskRuntime.tasks(Pageable.of(0, 2), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build()).getContent();
assertThat(allTasks.size()).isEqualTo(1);
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "interruptedMessage", "correlationKey", processInstance.getBusinessKey(), null));
assertThat(localEventSource.getEvents()).filteredOn(event -> event.getEventType().equals(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED)).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED, allTasks.get(0).getName()));
// sending the Interrupted Start Message to process
processRuntime.receive(MessagePayloadBuilder.receive("interruptedMessage").withCorrelationKey("correlationKey").build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "interruptedMessage", "correlationKey", processInstance.getBusinessKey(), null), Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "interruptedMessage", "correlationKey", processInstance.getBusinessKey(), null));
// then
assertThat(taskBaseRuntime.getTasksByProcessInstanceId(processInstance.getId())).isEmpty();
assertThat(localEventSource.getEvents()).filteredOn(event -> event.getEventType().equals(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED)).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, allTasks.get(0).getName()));
assertThat(localEventSource.getEvents()).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 ProcessRuntimeTerminatedEndEventIT method should_CancelledProcessesByTerminateEndEventsHaveCancellationReasonSet.
@Test
public void should_CancelledProcessesByTerminateEndEventsHaveCancellationReasonSet() {
// given
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_TERMINATE_EVENT).withName("to be terminated").withBusinessKey("My business key").build());
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).hasSize(2);
Task task2 = tasks.get(1);
// when
taskBaseRuntime.completeTask(task2.getId());
// then
List<Task> tasksAfterCompletion = taskBaseRuntime.getTasks(processInstance);
assertThat(tasksAfterCompletion).hasSize(0);
List<ProcessCancelledEvent> processCancelledEvents = localEventSource.getEvents(ProcessCancelledEvent.class);
assertThat(processCancelledEvents).hasSize(1);
ProcessCancelledEvent processCancelledEvent = processCancelledEvents.get(0);
assertThat(processCancelledEvent.getCause()).contains("Terminated by end event");
assertThat(processCancelledEvent.getEntity().getId()).isEqualTo(processInstance.getId());
assertThat(processCancelledEvent.getEntity().getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(processCancelledEvent.getEntity().getName()).isEqualTo(processInstance.getName());
assertThat(processCancelledEvent.getEntity().getBusinessKey()).isEqualTo(processInstance.getBusinessKey());
assertThat(processCancelledEvent.getEntity().getStartDate()).isEqualTo(processInstance.getStartDate());
assertThat(processCancelledEvent.getEntity().getInitiator()).isEqualTo(LOGGED_USER);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeBPMNErrorReceivedIT method should_CatchCallActivityBoundaryErrorEvent_When_ErrorEndEvenThrown.
@Test
public void should_CatchCallActivityBoundaryErrorEvent_When_ErrorEndEvenThrown() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(ERROR_BOUNDARY_EVENT_CALLACTIVITY).build());
assertThat(processInstance).isNotNull();
checkProcessAndTask(processInstance.getId(), "Task");
assertThat(listener.getErrorReceivedEvents()).isNotEmpty().extracting(BPMNErrorReceivedEvent::getEventType, BPMNErrorReceivedEvent::getProcessDefinitionId, BPMNErrorReceivedEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId(), event -> event.getEntity().getActivityName(), event -> event.getEntity().getActivityType(), event -> event.getEntity().getErrorId(), event -> event.getEntity().getErrorCode()).contains(Tuple.tuple(BPMNErrorReceivedEvent.ErrorEvents.ERROR_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "catchError", null, null, "errorId", "123"));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeBPMNErrorReceivedIT method checkTask.
private void checkTask(String processInstanceId, String taskName) {
GetTasksPayload getTasksPayload = new GetTasksPayloadBuilder().withProcessInstanceId(processInstanceId).build();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50), getTasksPayload);
assertThat(tasks.getContent()).hasSize(1);
assertThat(tasks.getContent().get(0).getName()).isEqualTo(taskName);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeBPMNErrorReceivedIT method should_StartSubProcess_When_ErrorEndEvenThrown.
@Test
public void should_StartSubProcess_When_ErrorEndEvenThrown() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(ERROR_START_EVENT_SUBPROCESS).build());
assertThat(processInstance).isNotNull();
checkProcessAndTask(processInstance.getId(), "Task");
assertThat(listener.getErrorReceivedEvents()).isNotEmpty().extracting(BPMNErrorReceivedEvent::getEventType, BPMNErrorReceivedEvent::getProcessDefinitionId, BPMNErrorReceivedEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId(), event -> event.getEntity().getActivityName(), event -> event.getEntity().getActivityType(), event -> event.getEntity().getErrorId(), event -> event.getEntity().getErrorCode()).contains(Tuple.tuple(BPMNErrorReceivedEvent.ErrorEvents.ERROR_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "subStart1", null, null, "errorId", "123"));
}
Aggregations