Search in sources :

Example 1 with BPMNTimerImpl

use of org.activiti.api.runtime.model.impl.BPMNTimerImpl 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 BPMNTimerImpl

use of org.activiti.api.runtime.model.impl.BPMNTimerImpl in project Activiti by Activiti.

the class ToTimerRetriesDecrementedConverterTest 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
    BPMNTimerRetriesDecrementedEvent timerEvent = toTimerConverter.from(internalEvent).orElse(null);
    // then
    assertThat(timerEvent).isNotNull();
    assertThat(timerEvent.getProcessInstanceId()).isEqualTo("procInstId");
    assertThat(timerEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(timerEvent.getEntity()).isEqualTo(bpmnTimer);
}
Also used : ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl) BPMNTimerRetriesDecrementedEvent(org.activiti.api.process.model.events.BPMNTimerRetriesDecrementedEvent) Test(org.junit.jupiter.api.Test)

Example 3 with BPMNTimerImpl

use of org.activiti.api.runtime.model.impl.BPMNTimerImpl in project Activiti by Activiti.

the class ToTimerExecutedConverterTest 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
    BPMNTimerExecutedEvent timerEvent = toTimerConverter.from(internalEvent).orElse(null);
    // then
    assertThat(timerEvent).isNotNull();
    assertThat(timerEvent.getProcessInstanceId()).isEqualTo("procInstId");
    assertThat(timerEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(timerEvent.getEntity()).isEqualTo(bpmnTimer);
}
Also used : ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl) BPMNTimerExecutedEvent(org.activiti.api.process.model.events.BPMNTimerExecutedEvent) Test(org.junit.jupiter.api.Test)

Example 4 with BPMNTimerImpl

use of org.activiti.api.runtime.model.impl.BPMNTimerImpl in project Activiti by Activiti.

the class BPMNTimerConverter method convertToBPMNTimer.

public BPMNTimerImpl convertToBPMNTimer(ActivitiEntityEvent internalEvent) {
    AbstractJobEntity jobEntity = (AbstractJobEntity) internalEvent.getEntity();
    BPMNTimerImpl timer = new BPMNTimerImpl(TimerEventHandler.getActivityIdFromConfiguration(jobEntity.getJobHandlerConfiguration()));
    timer.setProcessDefinitionId(internalEvent.getProcessDefinitionId());
    timer.setProcessInstanceId(internalEvent.getProcessInstanceId());
    timer.setTimerPayload(convertToTimerPayload(jobEntity));
    return timer;
}
Also used : AbstractJobEntity(org.activiti.engine.impl.persistence.entity.AbstractJobEntity) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl)

Example 5 with BPMNTimerImpl

use of org.activiti.api.runtime.model.impl.BPMNTimerImpl in project Activiti by Activiti.

the class ToTimerFiredConverterTest 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
    BPMNTimerFiredEvent timerEvent = toTimerConverter.from(internalEvent).orElse(null);
    // then
    assertThat(timerEvent).isNotNull();
    assertThat(timerEvent.getProcessInstanceId()).isEqualTo("procInstId");
    assertThat(timerEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(timerEvent.getEntity()).isEqualTo(bpmnTimer);
}
Also used : BPMNTimerFiredEvent(org.activiti.api.process.model.events.BPMNTimerFiredEvent) ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl) Test(org.junit.jupiter.api.Test)

Aggregations

BPMNTimerImpl (org.activiti.api.runtime.model.impl.BPMNTimerImpl)7 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)6 Test (org.junit.jupiter.api.Test)6 BPMNTimerCancelledEvent (org.activiti.api.process.model.events.BPMNTimerCancelledEvent)1 BPMNTimerExecutedEvent (org.activiti.api.process.model.events.BPMNTimerExecutedEvent)1 BPMNTimerFailedEvent (org.activiti.api.process.model.events.BPMNTimerFailedEvent)1 BPMNTimerFiredEvent (org.activiti.api.process.model.events.BPMNTimerFiredEvent)1 BPMNTimerRetriesDecrementedEvent (org.activiti.api.process.model.events.BPMNTimerRetriesDecrementedEvent)1 BPMNTimerScheduledEvent (org.activiti.api.process.model.events.BPMNTimerScheduledEvent)1 AbstractJobEntity (org.activiti.engine.impl.persistence.entity.AbstractJobEntity)1