use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class ActivityEventsTest method testActivityMessageBoundaryEventsOnSubProcess.
/**
* Test events related to message events, called from the API.
*/
@Deployment
public void testActivityMessageBoundaryEventsOnSubProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnSubProcess");
assertNotNull(processInstance);
Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("cloudformtask1").singleResult();
assertNotNull(executionWithMessage);
runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
assertEquals(2, listener.getEventsReceived().size());
// First, a message-event is expected
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
assertEquals("boundaryMessageEventCatching", messageEvent.getActivityId());
assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
assertEquals("message_1", messageEvent.getMessageName());
assertNull(messageEvent.getMessageData());
// Next, an signal-event is expected, as a result of the message
assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiActivityCancelledEvent);
ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
assertEquals("cloudformtask1", signalEvent.getActivityId());
assertEquals(executionWithMessage.getId(), signalEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNotNull(signalEvent.getCause());
assertTrue(signalEvent.getCause() instanceof MessageEventSubscriptionEntity);
MessageEventSubscriptionEntity cause = (MessageEventSubscriptionEntity) signalEvent.getCause();
assertEquals("message_1", cause.getEventName());
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventType.
public void testQueryByEventType() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
signalEventSubscriptionEntity3.setEventName("messageName2");
signalEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventType("signal").list();
assertEquals(1, list.size());
list = newEventSubscriptionQuery().eventType("message").list();
assertEquals(2, list.size());
cleanDb();
}
use of org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventName.
public void testQueryByEventName() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity3 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity3.setEventName("messageName2");
messageEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventName("messageName").list();
assertEquals(2, list.size());
list = newEventSubscriptionQuery().eventName("messageName2").list();
assertEquals(1, list.size());
cleanDb();
}
Aggregations