Search in sources :

Example 1 with BPMNMessageImpl

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);
}
Also used : BPMNMessageReceivedEvent(org.activiti.api.process.model.events.BPMNMessageReceivedEvent) BPMNMessageImpl(org.activiti.api.runtime.model.impl.BPMNMessageImpl) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Test(org.junit.jupiter.api.Test)

Example 2 with BPMNMessageImpl

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;
}
Also used : MessageEventPayload(org.activiti.api.process.model.payloads.MessageEventPayload) BPMNMessageImpl(org.activiti.api.runtime.model.impl.BPMNMessageImpl) Map(java.util.Map)

Example 3 with BPMNMessageImpl

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");
}
Also used : BPMNMessageImpl(org.activiti.api.runtime.model.impl.BPMNMessageImpl) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Test(org.junit.jupiter.api.Test)

Example 4 with BPMNMessageImpl

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);
}
Also used : BPMNMessageSentEvent(org.activiti.api.process.model.events.BPMNMessageSentEvent) BPMNMessageImpl(org.activiti.api.runtime.model.impl.BPMNMessageImpl) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Test(org.junit.jupiter.api.Test)

Example 5 with BPMNMessageImpl

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);
}
Also used : BPMNMessageWaitingEvent(org.activiti.api.process.model.events.BPMNMessageWaitingEvent) BPMNMessageImpl(org.activiti.api.runtime.model.impl.BPMNMessageImpl) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Test(org.junit.jupiter.api.Test)

Aggregations

BPMNMessageImpl (org.activiti.api.runtime.model.impl.BPMNMessageImpl)5 ActivitiMessageEvent (org.activiti.engine.delegate.event.ActivitiMessageEvent)4 Test (org.junit.jupiter.api.Test)4 Map (java.util.Map)1 BPMNMessageReceivedEvent (org.activiti.api.process.model.events.BPMNMessageReceivedEvent)1 BPMNMessageSentEvent (org.activiti.api.process.model.events.BPMNMessageSentEvent)1 BPMNMessageWaitingEvent (org.activiti.api.process.model.events.BPMNMessageWaitingEvent)1 MessageEventPayload (org.activiti.api.process.model.payloads.MessageEventPayload)1