ToErrorReceivedConverter implements EventConverter<BPMNErrorReceivedEvent, ActivitiErrorEvent> { @Override public Optional<BPMNErrorReceivedEvent> from(ActivitiErrorEvent internalEvent) { BPMNErrorReceivedEventImpl event = new BPMNErrorReceivedEventImpl(bpmnErrorConverter.convertToBPMNError(internalEvent)); event.setProcessInstanceId(internalEvent.getProcessInstanceId()); event.setProcessDefinitionId(internalEvent.getProcessDefinitionId()); return Optional.of(event); } ToErrorReceivedConverter(BPMNErrorConverter bpmnErrorConverter); @Override Optional<BPMNErrorReceivedEvent> from(ActivitiErrorEvent internalEvent);  }
@Test public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() { ActivitiErrorEvent internalEvent = mock(ActivitiErrorEvent.class); given(internalEvent.getProcessDefinitionId()).willReturn("procDefId"); given(internalEvent.getProcessInstanceId()).willReturn("procInstId"); BPMNErrorImpl bpmnError = new BPMNErrorImpl("myError"); given(bpmnErrorConverter.convertToBPMNError(internalEvent)).willReturn(bpmnError); BPMNErrorReceivedEvent errorEvent = toErrorReceivedConverter.from(internalEvent).orElse(null); assertThat(errorEvent).isNotNull(); assertThat(errorEvent.getProcessInstanceId()).isEqualTo("procInstId"); assertThat(errorEvent.getProcessDefinitionId()).isEqualTo("procDefId"); assertThat(errorEvent.getEntity()).isEqualTo(bpmnError); }