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);
}
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();
}
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();
}
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();
}
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();
}
Aggregations