Search in sources :

Example 1 with BPMNTimerCancelledEvent

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);
}
Also used : ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl) BPMNTimerCancelledEvent(org.activiti.api.process.model.events.BPMNTimerCancelledEvent) Test(org.junit.jupiter.api.Test)

Example 2 with BPMNTimerCancelledEvent

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"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) DummyBPMNTimerCancelledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerCancelledListener) Task(org.activiti.api.task.model.Task) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) DummyBPMNTimerScheduledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerScheduledListener) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) BPMNTimerEvent(org.activiti.api.process.model.events.BPMNTimerEvent) DummyBPMNTimerExecutedListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerExecutedListener) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Awaitility.await(org.awaitility.Awaitility.await) Tuple(org.assertj.core.groups.Tuple) BPMNTimerCancelledEvent(org.activiti.api.process.model.events.BPMNTimerCancelledEvent) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TaskPayloadBuilder(org.activiti.api.task.model.builders.TaskPayloadBuilder) Import(org.springframework.context.annotation.Import) Page(org.activiti.api.runtime.shared.query.Page) BPMNTimerScheduledEvent(org.activiti.api.process.model.events.BPMNTimerScheduledEvent) DummyBPMNTimerFiredListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerFiredListener) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) ProcessInstance(org.activiti.api.process.model.ProcessInstance) BPMNTimerCancelledEvent(org.activiti.api.process.model.events.BPMNTimerCancelledEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with BPMNTimerCancelledEvent

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"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) DummyBPMNTimerCancelledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerCancelledListener) Task(org.activiti.api.task.model.Task) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveProfiles(org.springframework.test.context.ActiveProfiles) DummyBPMNTimerScheduledListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerScheduledListener) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) BPMNTimerEvent(org.activiti.api.process.model.events.BPMNTimerEvent) DummyBPMNTimerExecutedListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerExecutedListener) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Awaitility.await(org.awaitility.Awaitility.await) Tuple(org.assertj.core.groups.Tuple) BPMNTimerCancelledEvent(org.activiti.api.process.model.events.BPMNTimerCancelledEvent) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TaskPayloadBuilder(org.activiti.api.task.model.builders.TaskPayloadBuilder) Import(org.springframework.context.annotation.Import) Page(org.activiti.api.runtime.shared.query.Page) BPMNTimerScheduledEvent(org.activiti.api.process.model.events.BPMNTimerScheduledEvent) DummyBPMNTimerFiredListener(org.activiti.spring.boot.process.listener.DummyBPMNTimerFiredListener) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Task(org.activiti.api.task.model.Task) BPMNTimerScheduledEvent(org.activiti.api.process.model.events.BPMNTimerScheduledEvent) ProcessInstance(org.activiti.api.process.model.ProcessInstance) BPMNTimerCancelledEvent(org.activiti.api.process.model.events.BPMNTimerCancelledEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BPMNTimerCancelledEvent (org.activiti.api.process.model.events.BPMNTimerCancelledEvent)3 Test (org.junit.jupiter.api.Test)3 Date (java.util.Date)2 List (java.util.List)2 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)2 ProcessInstance (org.activiti.api.process.model.ProcessInstance)2 BPMNTimerEvent (org.activiti.api.process.model.events.BPMNTimerEvent)2 BPMNTimerScheduledEvent (org.activiti.api.process.model.events.BPMNTimerScheduledEvent)2 Page (org.activiti.api.runtime.shared.query.Page)2 Pageable (org.activiti.api.runtime.shared.query.Pageable)2 Task (org.activiti.api.task.model.Task)2 TaskPayloadBuilder (org.activiti.api.task.model.builders.TaskPayloadBuilder)2 TaskRuntime (org.activiti.api.task.runtime.TaskRuntime)2 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)2 DummyBPMNTimerCancelledListener (org.activiti.spring.boot.process.listener.DummyBPMNTimerCancelledListener)2 DummyBPMNTimerExecutedListener (org.activiti.spring.boot.process.listener.DummyBPMNTimerExecutedListener)2 DummyBPMNTimerFiredListener (org.activiti.spring.boot.process.listener.DummyBPMNTimerFiredListener)2 DummyBPMNTimerScheduledListener (org.activiti.spring.boot.process.listener.DummyBPMNTimerScheduledListener)2 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)2 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)2