use of org.activiti.api.task.runtime.events.TaskCancelledEvent in project Activiti by Activiti.
the class ToTaskCancelledConverterTest method should_ReturnEmpty_when_entityIsANonCancelledTask.
@Test
public void should_ReturnEmpty_when_entityIsANonCancelledTask() {
// given
Task internalTask = taskEntityBuilder().withCancelled(false).build();
ActivitiEntityEventImpl internalEvent = new ActivitiEntityEventImpl(internalTask, ActivitiEventType.ENTITY_DELETED);
// when
Optional<TaskCancelledEvent> convertedTaskCancelledEvent = eventConverter.from(internalEvent);
// then
assertThat(convertedTaskCancelledEvent).isEmpty();
}
use of org.activiti.api.task.runtime.events.TaskCancelledEvent in project Activiti by Activiti.
the class ToTaskCancelledConverterTest method should_returnConvertedTask_when_entityIsACancelledTask.
@Test
public void should_returnConvertedTask_when_entityIsACancelledTask() {
// given
Task internalTask = taskEntityBuilder().withCancelled(true).build();
ActivitiEntityEventImpl internalEvent = new ActivitiEntityEventImpl(internalTask, ActivitiEventType.ENTITY_DELETED);
TaskImpl apiTask = new TaskImpl("id", "myTask", org.activiti.api.task.model.Task.TaskStatus.CANCELLED);
given(taskConverter.from(internalTask, org.activiti.api.task.model.Task.TaskStatus.CANCELLED)).willReturn(apiTask);
// when
TaskCancelledEvent convertedTaskCancelledEvent = eventConverter.from(internalEvent).orElse(null);
// then
assertThat(convertedTaskCancelledEvent).isNotNull();
assertThat(convertedTaskCancelledEvent.getEntity()).isEqualTo(apiTask);
assertThat(convertedTaskCancelledEvent.getEventType()).isEqualTo(TaskRuntimeEvent.TaskEvents.TASK_CANCELLED);
}
use of org.activiti.api.task.runtime.events.TaskCancelledEvent in project Activiti by Activiti.
the class ToTaskCancelledConverterTest method should_returnEmpty_when_entityIsNotTask.
@Test
public void should_returnEmpty_when_entityIsNotTask() {
// given
ActivitiEntityEventImpl internalEvent = new ActivitiEntityEventImpl(mock(ProcessInstance.class), ActivitiEventType.ENTITY_DELETED);
// when
Optional<TaskCancelledEvent> convertedTaskCancelledEvent = eventConverter.from(internalEvent);
// then
assertThat(convertedTaskCancelledEvent).isEmpty();
}
use of org.activiti.api.task.runtime.events.TaskCancelledEvent in project Activiti by Activiti.
the class TaskRuntimeTerminateEndEventTest method should_CancelledTasksByTerminateEndEventHaveCancellationReasonSet.
@Test
public void should_CancelledTasksByTerminateEndEventHaveCancellationReasonSet() {
securityUtil.logInAs("user");
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TERMINATE_EVENT);
assertThat(processInstance).isNotNull();
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).hasSize(2);
Task task2 = tasks.get(1);
taskBaseRuntime.completeTask(task2.getId());
List<Task> tasksAfterCompletion = taskBaseRuntime.getTasks(processInstance);
assertThat(tasksAfterCompletion).hasSize(0);
List<TaskCancelledEvent> taskCancelledEvents = localEventSource.getEvents(TaskCancelledEvent.class);
assertThat(taskCancelledEvents).hasSize(1);
assertThat(taskCancelledEvents.get(0).getReason()).contains("Terminated by end event");
}
use of org.activiti.api.task.runtime.events.TaskCancelledEvent in project Activiti by Activiti.
the class ToTaskCancelledConverter method from.
@Override
public Optional<TaskCancelledEvent> from(ActivitiEntityEvent internalEvent) {
TaskCancelledEvent event = null;
if (isTaskCancelled(internalEvent)) {
TaskEntity taskEntity = (TaskEntity) internalEvent.getEntity();
Task task = taskConverter.from(taskEntity, Task.TaskStatus.CANCELLED);
String reason = internalEvent.getReason();
event = new TaskCancelledImpl(task, reason);
}
return Optional.ofNullable(event);
}
Aggregations