Search in sources :

Example 1 with ProcessCancelledEvent

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);
}
Also used : Task(org.activiti.api.task.model.Task) ProcessCancelledEvent(org.activiti.api.process.runtime.events.ProcessCancelledEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with ProcessCancelledEvent

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);
}
Also used : ProcessCancelledEvent(org.activiti.api.process.runtime.events.ProcessCancelledEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProcessInstance (org.activiti.api.process.model.ProcessInstance)2 ProcessCancelledEvent (org.activiti.api.process.runtime.events.ProcessCancelledEvent)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Task (org.activiti.api.task.model.Task)1