use of org.activiti.api.process.model.events.BPMNTimerCancelledEvent in project Activiti by Activiti.
the class ToTimerCancelledConverterTest method shouldReturnConvertedEventsWhenInternalEvenIsRelatedToTimers.
@Test
public void shouldReturnConvertedEventsWhenInternalEvenIsRelatedToTimers() {
// given
ActivitiEntityEvent internalEvent = mock(ActivitiEntityEvent.class);
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNTimerImpl bpmnTimer = new BPMNTimerImpl("myTimer");
given(bpmnTimerConverter.convertToBPMNTimer(internalEvent)).willReturn(bpmnTimer);
given(bpmnTimerConverter.isTimerRelatedEvent(internalEvent)).willReturn(true);
// when
BPMNTimerCancelledEvent timerCancelledEvent = toTimerCancelledConverter.from(internalEvent).orElse(null);
// then
assertThat(timerCancelledEvent).isNotNull();
assertThat(timerCancelledEvent.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(timerCancelledEvent.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(timerCancelledEvent.getEntity()).isEqualTo(bpmnTimer);
}
use of org.activiti.api.process.model.events.BPMNTimerCancelledEvent in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventByProcessDelete.
@Test
public void shouldGetTimerCanceledEventByProcessDelete() {
// GIVEN
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
// WHEN
processBaseRuntime.delete(processInstance.getId());
// THEN
List<BPMNTimerCancelledEvent> eventsCancelled = listenerCancelled.getEvents();
assertThat(eventsCancelled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
use of org.activiti.api.process.model.events.BPMNTimerCancelledEvent in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventOnBoundaryEvent.
@Test
public void shouldGetTimerCanceledEventOnBoundaryEvent() {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
clear();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build());
List<BPMNTimerCancelledEvent> eventsCanceled = listenerCancelled.getEvents();
assertThat(eventsCanceled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
Aggregations