ToSignalReceivedConverter implements EventConverter<BPMNSignalReceivedEvent, ActivitiSignalEvent> { @Override public Optional<BPMNSignalReceivedEvent> from(ActivitiSignalEvent internalEvent) { BPMNSignalReceivedEventImpl event = new BPMNSignalReceivedEventImpl(toSignalConverter.from(internalEvent)); event.setProcessInstanceId(internalEvent.getProcessInstanceId()); event.setProcessDefinitionId(internalEvent.getProcessDefinitionId()); return Optional.of(event); } ToSignalReceivedConverter(ToSignalConverter toSignalConverter); @Override Optional<BPMNSignalReceivedEvent> from(ActivitiSignalEvent internalEvent);  }
@Test public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() { ActivitiSignalEventImpl internalEvent = new ActivitiSignalEventImpl(ActivitiEventType.ACTIVITY_SIGNALED); internalEvent.setProcessDefinitionId("procDefId"); internalEvent.setProcessInstanceId("procInstId"); BPMNSignalImpl bpmnSignal = new BPMNSignalImpl(); given(toSignalConverter.from(internalEvent)).willReturn(bpmnSignal); BPMNSignalReceivedEvent bpmnSignalReceivedEvent = toSignalReceivedConverter.from(internalEvent).orElse(null); assertThat(bpmnSignalReceivedEvent).isNotNull(); assertThat(bpmnSignalReceivedEvent.getEntity()).isEqualTo(bpmnSignal); assertThat(bpmnSignalReceivedEvent.getProcessDefinitionId()).isEqualTo("procDefId"); assertThat(bpmnSignalReceivedEvent.getProcessInstanceId()).isEqualTo("procInstId"); }