use of org.activiti.api.runtime.model.impl.BPMNMessageImpl in project Activiti by Activiti.
the class ToMessageReceivedConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.
@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
// given
ActivitiMessageEvent internalEvent = mock(ActivitiMessageEvent.class);
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNMessageImpl bpmnMessage = new BPMNMessageImpl("myMessage");
given(bpmnMessageConverter.convertToBPMNMessage(internalEvent)).willReturn(bpmnMessage);
// when
BPMNMessageReceivedEvent messageEvent = toMessageConverter.from(internalEvent).orElse(null);
// then
assertThat(messageEvent).isNotNull();
assertThat(messageEvent.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(messageEvent.getEntity()).isEqualTo(bpmnMessage);
}
use of org.activiti.api.runtime.model.impl.BPMNMessageImpl in project Activiti by Activiti.
the class BPMNMessageConverter method convertToBPMNMessage.
@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;
}
use of org.activiti.api.runtime.model.impl.BPMNMessageImpl in project Activiti by Activiti.
the class BPMNMessageConverterTest method convertShouldReturnBPMNMessage.
@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);
// then
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");
}
use of org.activiti.api.runtime.model.impl.BPMNMessageImpl in project Activiti by Activiti.
the class ToMessageSentConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.
@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
// given
ActivitiMessageEvent internalEvent = mock(ActivitiMessageEvent.class);
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNMessageImpl bpmnMessage = new BPMNMessageImpl("myMessage");
given(bpmnMessageConverter.convertToBPMNMessage(internalEvent)).willReturn(bpmnMessage);
// when
BPMNMessageSentEvent messageEvent = toMessageConverter.from(internalEvent).orElse(null);
// then
assertThat(messageEvent).isNotNull();
assertThat(messageEvent.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(messageEvent.getEntity()).isEqualTo(bpmnMessage);
}
use of org.activiti.api.runtime.model.impl.BPMNMessageImpl in project Activiti by Activiti.
the class ToMessageWaitingConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.
@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
// given
ActivitiMessageEvent internalEvent = mock(ActivitiMessageEvent.class);
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNMessageImpl bpmnMessage = new BPMNMessageImpl("myMessage");
given(bpmnMessageConverter.convertToBPMNMessage(internalEvent)).willReturn(bpmnMessage);
// when
BPMNMessageWaitingEvent messageEvent = toMessageConverter.from(internalEvent).orElse(null);
// then
assertThat(messageEvent).isNotNull();
assertThat(messageEvent.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(messageEvent.getEntity()).isEqualTo(bpmnMessage);
}
Aggregations