Search in sources :

Example 1 with BPMNSignalImpl

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

the class ToSignalConverter method from.

@SuppressWarnings("unchecked")
public BPMNSignal from(ActivitiSignalEvent internalEvent) {
    BPMNSignalImpl signal = new BPMNSignalImpl(internalEvent.getActivityId());
    signal.setProcessDefinitionId(internalEvent.getProcessDefinitionId());
    signal.setProcessInstanceId(internalEvent.getProcessInstanceId());
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName(internalEvent.getSignalName()).build();
    if (internalEvent.getSignalData() != null) {
        Map<String, Object> sourceVariables = (Map<String, Object>) internalEvent.getSignalData();
        signalPayload.setVariables(new HashMap<>(sourceVariables));
    }
    signal.setSignalPayload(signalPayload);
    return signal;
}
Also used : BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with BPMNSignalImpl

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

Aggregations

BPMNSignalImpl (org.activiti.api.runtime.model.impl.BPMNSignalImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BPMNSignalReceivedEvent (org.activiti.api.process.model.events.BPMNSignalReceivedEvent)1 SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)1 ActivitiSignalEventImpl (org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl)1 Test (org.junit.jupiter.api.Test)1