Search in sources :

Example 1 with ActivitiMessageEvent

use of org.activiti.engine.delegate.event.ActivitiMessageEvent 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 ActivitiMessageEvent

use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.

the class MessageThrowEventTest method testThrowMessageEndEvent.

@Deployment
public void testThrowMessageEndEvent() throws Exception {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testThrowMessageEndEvent");
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(listenerExecuted).isTrue();
    assertThat(receivedEvents).hasSize(1);
    ActivitiMessageEvent event = (ActivitiMessageEvent) receivedEvents.get(0);
    assertThat(event.getActivityId()).isEqualTo("theEnd");
    assertThat(event.getActivityType()).isEqualTo("endEvent");
    assertThat(event.getActivityName()).isEqualTo("Throw Message");
    assertThat(event.getBehaviorClass()).isEqualTo(ThrowMessageEndEventActivityBehavior.class.getName());
    assertThat(event.getMessageName()).isEqualTo("endMessage");
    assertThat(event.getMessageData()).isNull();
    assertThat(event.getProcessDefinitionId()).isEqualTo(pi.getProcessDefinitionId());
    assertThat(event.getProcessInstanceId()).isEqualTo(pi.getId());
    assertThat(event.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_SENT);
    assertThat(event.getExecutionId()).isNotNull();
}
Also used : ThrowMessageEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ActivitiMessageEvent

use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.

the class MessageThrowEventTest method testIntermediateThrowMessageEventJavaDelegate.

@Deployment
public void testIntermediateThrowMessageEventJavaDelegate() throws Exception {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testIntermediateThrowMessageEventJavaDelegate");
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(message.getName()).isEqualTo("bpmnMessage");
    assertThat(delegateExecuted).isTrue();
    assertThat(receivedEvents).hasSize(1);
    ActivitiMessageEvent event = (ActivitiMessageEvent) receivedEvents.get(0);
    assertThat(event.getActivityId()).isEqualTo("messageThrow");
    assertThat(event.getActivityType()).isEqualTo("throwEvent");
    assertThat(event.getActivityName()).isEqualTo("Throw Message");
    assertThat(event.getBehaviorClass()).isEqualTo(IntermediateThrowMessageEventActivityBehavior.class.getName());
    assertThat(event.getMessageName()).isEqualTo("bpmnMessage");
    assertThat(event.getMessageData()).isNotNull();
    assertThat(event.getProcessDefinitionId()).isEqualTo(pi.getProcessDefinitionId());
    assertThat(event.getProcessInstanceId()).isEqualTo(pi.getId());
    assertThat(event.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_SENT);
    assertThat(event.getExecutionId()).isNotNull();
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) IntermediateThrowMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Deployment(org.activiti.engine.test.Deployment)

Example 4 with ActivitiMessageEvent

use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.

the class MessageThrowEventTest method testThrowMessageEndEventExpression.

@Deployment
public void testThrowMessageEndEventExpression() throws Exception {
    ProcessInstance pi = runtimeService.createProcessInstanceBuilder().processDefinitionKey("testThrowMessageEndEventExpression").businessKey("bar").start();
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(message.getName()).isEqualTo("endMessage-bar");
    assertThat(delegateExecuted);
    assertThat(receivedEvents.size() > 0);
    ActivitiMessageEvent event = (ActivitiMessageEvent) receivedEvents.get(0);
    assertThat(event.getActivityId()).isEqualTo("theEnd");
    assertThat(event.getActivityType()).isEqualTo("endEvent");
    assertThat(event.getActivityName()).isEqualTo("Throw Message");
    assertThat(event.getBehaviorClass()).isEqualTo(ThrowMessageEndEventActivityBehavior.class.getName());
    assertThat(event.getMessageName()).isEqualTo("endMessage-bar");
    assertThat(event.getMessageData()).isNotNull();
    assertThat(event.getMessageBusinessKey()).isEqualTo("bar");
    assertThat(event.getProcessDefinitionId()).isEqualTo(pi.getProcessDefinitionId());
    assertThat(event.getProcessInstanceId()).isEqualTo(pi.getId());
    assertThat(event.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_SENT);
    assertThat(event.getExecutionId()).isNotNull();
}
Also used : ThrowMessageEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Deployment(org.activiti.engine.test.Deployment)

Example 5 with ActivitiMessageEvent

use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.

the class MessageThrowEventTest method testIntermediateThrowMessageEvent.

@Deployment
public void testIntermediateThrowMessageEvent() throws Exception {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testIntermediateThrowMessageEvent");
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(listenerExecuted).isTrue();
    assertThat(receivedEvents).hasSize(1);
    ActivitiMessageEvent event = (ActivitiMessageEvent) receivedEvents.get(0);
    assertThat(event.getActivityId()).isEqualTo("messageThrow");
    assertThat(event.getActivityType()).isEqualTo("throwEvent");
    assertThat(event.getActivityName()).isEqualTo("Throw Message");
    assertThat(event.getBehaviorClass()).isEqualTo(IntermediateThrowMessageEventActivityBehavior.class.getName());
    assertThat(event.getMessageName()).isEqualTo("bpmnMessage");
    assertThat(event.getMessageData()).isNull();
    assertThat(event.getProcessDefinitionId()).isEqualTo(pi.getProcessDefinitionId());
    assertThat(event.getProcessInstanceId()).isEqualTo(pi.getId());
    assertThat(event.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_SENT);
    assertThat(event.getExecutionId()).isNotNull();
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) IntermediateThrowMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior) ActivitiMessageEvent(org.activiti.engine.delegate.event.ActivitiMessageEvent) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ActivitiMessageEvent (org.activiti.engine.delegate.event.ActivitiMessageEvent)18 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)13 Deployment (org.activiti.engine.test.Deployment)13 IntermediateThrowMessageEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior)5 BPMNMessageImpl (org.activiti.api.runtime.model.impl.BPMNMessageImpl)4 ThrowMessageEndEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior)4 Execution (org.activiti.engine.runtime.Execution)4 Test (org.junit.jupiter.api.Test)4 ActivitiActivityCancelledEvent (org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent)2 HashMap (java.util.HashMap)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 ActivitiActivityEvent (org.activiti.engine.delegate.event.ActivitiActivityEvent)1