BPMNMessageConverter { @SuppressWarnings("unchecked") public BPMNMessageImpl convertToBPMNMessage(ActivitiMessageEvent internalEvent) { BPMNMessageImpl bpmnMessage = new BPMNMessageImpl(internalEvent.getActivityId()); bpmnMessage.setProcessDefinitionId(internalEvent.getProcessDefinitionId()); bpmnMessage.setProcessInstanceId(internalEvent.getProcessInstanceId()); bpmnMessage.setMessagePayload(new MessageEventPayload(internalEvent.getMessageName(), internalEvent.getMessageCorrelationKey(), internalEvent.getMessageBusinessKey(), (Map<String, Object>)internalEvent.getMessageData())); return bpmnMessage; }  @SuppressWarnings("unchecked") BPMNMessageImpl convertToBPMNMessage(ActivitiMessageEvent internalEvent);  }
@Test public void convertShouldReturnBPMNMessage() { ActivitiMessageEvent internalEvent = mock(ActivitiMessageEvent.class); given(internalEvent.getMessageBusinessKey()).willReturn("businessKey"); given(internalEvent.getMessageCorrelationKey()).willReturn("correlationKey"); given(internalEvent.getMessageName()).willReturn("messageName"); given(internalEvent.getProcessDefinitionId()).willReturn("procDefId"); given(internalEvent.getProcessInstanceId()).willReturn("procInstId"); BPMNMessageImpl bpmnMessage = bpmnMessageConverter.convertToBPMNMessage(internalEvent); assertThat(bpmnMessage).isNotNull(); assertThat(bpmnMessage.getProcessInstanceId()).isEqualTo("procInstId"); assertThat(bpmnMessage.getProcessDefinitionId()).isEqualTo("procDefId"); assertThat(bpmnMessage.getMessagePayload()) .isNotNull() .extracting(MessageEventPayload::getName, MessageEventPayload::getBusinessKey, MessageEventPayload::getCorrelationKey) .contains("messageName", "businessKey", "correlationKey"); }