use of org.activiti.api.process.runtime.events.ProcessCancelledEvent 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.process.runtime.events.ProcessCancelledEvent in project Activiti by Activiti.
the class ProcessRuntimeEventsIT method should_emmitEventOnProcessDeletion.
@Test
public void should_emmitEventOnProcessDeletion() {
// given
ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(SINGLE_TASK_PROCESS).withName("to be deleted").withBusinessKey("my business key").build());
// when
processRuntime.delete(ProcessPayloadBuilder.delete(processInstance));
// then
List<ProcessCancelledEvent> processCancelledEvents = localEventSource.getEvents(ProcessCancelledEvent.class);
assertThat(processCancelledEvents).hasSize(1);
ProcessCancelledEvent processCancelledEvent = processCancelledEvents.get(0);
assertThat(processCancelledEvent.getCause()).isEqualTo("process instance deleted");
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);
}
Aggregations