Search in sources :

Example 11 with ActivitiMessageEvent

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

the class MessageThrowEventTest method testThrowMessageEndEventCorrelationKeyExpression.

@Deployment
public void testThrowMessageEndEventCorrelationKeyExpression() throws Exception {
    ProcessInstance pi = runtimeService.createProcessInstanceBuilder().variable("foo", "bar").processDefinitionKey("process").start();
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(listenerExecuted).isTrue();
    assertThat(message.getCorrelationKey().isPresent()).isTrue();
    assertThat(message.getCorrelationKey().get()).isEqualTo("bar");
    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.getMessageCorrelationKey()).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 12 with ActivitiMessageEvent

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

the class MessageThrowEventTest method testThrowMessageEndEventJavaDelegate.

@Deployment
public void testThrowMessageEndEventJavaDelegate() throws Exception {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testThrowMessageEndEventJavaDelegate");
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(message.getName()).isEqualTo("endMessage");
    assertThat(delegateExecuted).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()).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 : 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 13 with ActivitiMessageEvent

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

the class MessageThrowEventTest method testIntermediateThrowMessageEventFieldExtensions.

@Deployment
public void testIntermediateThrowMessageEventFieldExtensions() throws Exception {
    ProcessInstance pi = runtimeService.createProcessInstanceBuilder().processDefinitionKey("process").variable("foo", "bar").businessKey("customerId").start();
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(message.getName()).isEqualTo("bpmnMessage");
    assertThat(delegateExecuted);
    assertThat(receivedEvents.size() > 0);
    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.getMessageBusinessKey()).isEqualTo("customerId");
    assertThat(event.getMessageData()).as("should map payload from field extensions").isInstanceOf(Map.class).extracting("foo", "businessKey", "key", "bar").containsExactly("bar", "customerId", "value", null);
    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 14 with ActivitiMessageEvent

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

the class MessageThrowEventTest method testIntermediateThrowMessageEventExpression.

@Deployment
public void testIntermediateThrowMessageEventExpression() throws Exception {
    ProcessInstance pi = runtimeService.createProcessInstanceBuilder().processDefinitionKey("testIntermediateThrowMessageEventExpression").businessKey("foo").start();
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(message.getName()).isEqualTo("bpmnMessage-foo");
    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-foo");
    assertThat(event.getMessageData()).isNotNull();
    assertThat(event.getMessageBusinessKey()).isEqualTo("foo");
    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 15 with ActivitiMessageEvent

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

the class MessageThrowEventTest method testIntermediateThrowMessageEventCorrelationKeyExpression.

@Deployment
public void testIntermediateThrowMessageEventCorrelationKeyExpression() throws Exception {
    ProcessInstance pi = runtimeService.createProcessInstanceBuilder().variable("foo", "bar").processDefinitionKey("process").start();
    assertProcessEnded(pi.getProcessInstanceId());
    assertThat(listenerExecuted).isTrue();
    assertThat(message.getCorrelationKey().isPresent()).isTrue();
    assertThat(message.getCorrelationKey().get()).isEqualTo("bar");
    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.getMessageCorrelationKey()).isEqualTo("bar");
    assertThat(event.getMessageData()).isNull();
    assertThat(event.getMessageBusinessKey()).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