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");
}
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)");
}
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);
}
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");
}
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)");
}
Aggregations