Search in sources :

Example 1 with ActivitiSignalEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl in project Activiti by Activiti.

the class ToSignalConverterTest method fromShouldSetMetaInfoAndVariables.

@Test
public void fromShouldSetMetaInfoAndVariables() {
    // given
    ActivitiSignalEventImpl internalEvent = new ActivitiSignalEventImpl(ActivitiEventType.ACTIVITY_SIGNALED);
    internalEvent.setSignalName("go");
    internalEvent.setSignalData(singletonMap("signalVar", "value"));
    internalEvent.setProcessDefinitionId("procDefId");
    internalEvent.setProcessInstanceId("procInstId");
    // when
    BPMNSignal signal = toSignalConverter.from(internalEvent);
    // then
    assertThat(signal.getSignalPayload().getName()).isEqualTo("go");
    assertThat(signal.getSignalPayload().getVariables()).containsEntry("signalVar", "value");
    assertThat(signal.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(signal.getProcessInstanceId()).isEqualTo("procInstId");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) BPMNSignal(org.activiti.api.process.model.BPMNSignal) Test(org.junit.jupiter.api.Test)

Example 2 with ActivitiSignalEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl in project Activiti by Activiti.

the class ActivityEventsTest method testActivitySignalBoundaryEventsOnSubProcess.

@Deployment
public void testActivitySignalBoundaryEventsOnSubProcess() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalOnSubProcess");
    assertThat(processInstance).isNotNull();
    Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("userTaskInsideProcess").singleResult();
    assertThat(executionWithSignal).isNotNull();
    runtimeService.signalEventReceived("signalName");
    assertThat(listener.getEventsReceived()).hasSize(3);
    assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiSignalEventImpl.class);
    ActivitiSignalEventImpl signalEvent = (ActivitiSignalEventImpl) listener.getEventsReceived().get(0);
    assertThat(signalEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_SIGNALED);
    assertThat(signalEvent.getActivityId()).isEqualTo("boundarySignalEventCatching");
    assertThat(signalEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(signalEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(listener.getEventsReceived().get(2)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    ActivitiActivityCancelledEvent cancelEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(2);
    assertThat(cancelEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelEvent.getActivityId()).isEqualTo("subProcess");
    assertThat(cancelEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(cancelEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelEvent.getCause()).isEqualTo("boundary event (boundarySignalEventCatching)");
    assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    cancelEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
    assertThat(cancelEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelEvent.getActivityId()).isEqualTo("userTaskInsideProcess");
    assertThat(cancelEvent.getExecutionId()).isEqualTo(executionWithSignal.getId());
    assertThat(cancelEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(cancelEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelEvent.getCause()).isEqualTo("boundary event (boundarySignalEventCatching)");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) Execution(org.activiti.engine.runtime.Execution) ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ActivitiSignalEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl in project Activiti by Activiti.

the class SignalReceivedListenerDelegateTest method onEventShouldCallOnAvailableListenersWhenIsASignalEvent.

@Test
public void onEventShouldCallOnAvailableListenersWhenIsASignalEvent() {
    // given
    ActivitiSignalEventImpl internalEvent = new ActivitiSignalEventImpl(ActivitiEventType.ACTIVITY_SIGNALED);
    BPMNSignalReceivedEventImpl signalReceivedEvent = new BPMNSignalReceivedEventImpl();
    given(converter.from(internalEvent)).willReturn(Optional.of(signalReceivedEvent));
    // when
    listenerDelegate.onEvent(internalEvent);
    // then
    verify(firstListener).onEvent(signalReceivedEvent);
    verify(secondListener).onEvent(signalReceivedEvent);
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) BPMNSignalReceivedEventImpl(org.activiti.api.runtime.event.impl.BPMNSignalReceivedEventImpl) Test(org.junit.jupiter.api.Test)

Example 4 with ActivitiSignalEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl in project Activiti by Activiti.

the class ToSignalReceivedConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.

@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
    // given
    ActivitiSignalEventImpl internalEvent = new ActivitiSignalEventImpl(ActivitiEventType.ACTIVITY_SIGNALED);
    internalEvent.setProcessDefinitionId("procDefId");
    internalEvent.setProcessInstanceId("procInstId");
    BPMNSignalImpl bpmnSignal = new BPMNSignalImpl();
    given(toSignalConverter.from(internalEvent)).willReturn(bpmnSignal);
    // when
    BPMNSignalReceivedEvent bpmnSignalReceivedEvent = toSignalReceivedConverter.from(internalEvent).orElse(null);
    // then
    assertThat(bpmnSignalReceivedEvent).isNotNull();
    assertThat(bpmnSignalReceivedEvent.getEntity()).isEqualTo(bpmnSignal);
    assertThat(bpmnSignalReceivedEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(bpmnSignalReceivedEvent.getProcessInstanceId()).isEqualTo("procInstId");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) Test(org.junit.jupiter.api.Test)

Example 5 with ActivitiSignalEventImpl

use of org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl in project Activiti by Activiti.

the class ActivityEventsTest method testActivitySignalBoundaryEventsOnUserTask.

@Deployment
public void testActivitySignalBoundaryEventsOnUserTask() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalOnUserTask");
    assertThat(processInstance).isNotNull();
    Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("userTask").singleResult();
    assertThat(executionWithSignal).isNotNull();
    runtimeService.signalEventReceived("signalName");
    // Next, an signal-event is expected, as a result of the message
    assertThat(listener.getEventsReceived()).hasSize(2);
    assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiSignalEventImpl.class);
    ActivitiSignalEventImpl signalEvent = (ActivitiSignalEventImpl) listener.getEventsReceived().get(0);
    assertThat(signalEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_SIGNALED);
    assertThat(signalEvent.getActivityId()).isEqualTo("boundarySignalEventCatching");
    assertThat(signalEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(signalEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiActivityCancelledEvent.class);
    ActivitiActivityCancelledEvent cancelEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
    assertThat(cancelEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
    assertThat(cancelEvent.getActivityId()).isEqualTo("userTask");
    assertThat(cancelEvent.getProcessInstanceId()).isEqualTo(executionWithSignal.getProcessInstanceId());
    assertThat(cancelEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
    assertThat(cancelEvent.getCause()).isEqualTo("boundary event (boundarySignalEventCatching)");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) Execution(org.activiti.engine.runtime.Execution) ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ActivitiSignalEventImpl (org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl)5 Test (org.junit.jupiter.api.Test)3 ActivitiActivityCancelledEvent (org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent)2 Execution (org.activiti.engine.runtime.Execution)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 Deployment (org.activiti.engine.test.Deployment)2 BPMNSignal (org.activiti.api.process.model.BPMNSignal)1 BPMNSignalReceivedEvent (org.activiti.api.process.model.events.BPMNSignalReceivedEvent)1 BPMNSignalReceivedEventImpl (org.activiti.api.runtime.event.impl.BPMNSignalReceivedEventImpl)1 BPMNSignalImpl (org.activiti.api.runtime.model.impl.BPMNSignalImpl)1