use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnSingleReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.singleReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnSingleReceiveTask() {
// given: a process instance waiting in the receive task
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there is a message event subscription for the task
List<EventSubscription> subscriptionList = getEventSubscriptionList();
assertEquals(1, subscriptionList.size());
EventSubscription subscription = subscriptionList.get(0);
// then: we can trigger the event subscription
runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
// expect: subscription is removed
assertEquals(0, getEventSubscriptionList().size());
// expect: this ends the process instance
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testNotSupportsCorrelateMessageOnParallelMultiReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml")
public void testNotSupportsCorrelateMessageOnParallelMultiReceiveTask() {
// given: a process instance waiting in two receive tasks
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there are two message event subscriptions
List<EventSubscription> subscriptions = getEventSubscriptionList();
assertEquals(2, subscriptions.size());
// then: we can not correlate an event
try {
runtimeService.correlateMessage(subscriptions.get(0).getEventName());
fail("should throw a mismatch");
} catch (MismatchingMessageCorrelationException e) {
// expected
}
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnSubProcessReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.subProcessReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnSubProcessReceiveTask() {
// given: a process instance waiting in the sub-process receive task
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there is a message event subscription for the task
List<EventSubscription> subscriptionList = getEventSubscriptionList();
assertEquals(1, subscriptionList.size());
EventSubscription subscription = subscriptionList.get(0);
// then: we can trigger the event subscription
runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
// expect: subscription is removed
assertEquals(0, getEventSubscriptionList().size());
// expect: this ends the process instance
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsLegacySignalingOnParallelMultiReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml")
public void testSupportsLegacySignalingOnParallelMultiReceiveTask() {
// given: a process instance waiting in two receive tasks
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there are two message event subscriptions
List<EventSubscription> subscriptions = getEventSubscriptionList();
assertEquals(2, subscriptions.size());
// expect: there are two executions
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("waitState").messageEventSubscriptionName("newInvoiceMessage").list();
assertEquals(2, executions.size());
// then: we can signal both waiting receive task
runtimeService.signal(executions.get(0).getId());
runtimeService.signal(executions.get(1).getId());
// expect: both event subscriptions are removed
assertEquals(0, getEventSubscriptionList().size());
// expect: this ends the process instance
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnSequentialMultiReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnSequentialMultiReceiveTask() {
// given: a process instance waiting in the first receive tasks
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there is a message event subscription for the first task
List<EventSubscription> subscriptionList = getEventSubscriptionList();
assertEquals(1, subscriptionList.size());
EventSubscription subscription = subscriptionList.get(0);
String firstSubscriptionId = subscription.getId();
// then: we can trigger the event subscription
runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
// expect: there is a new subscription created for the second receive task instance
subscriptionList = getEventSubscriptionList();
assertEquals(1, subscriptionList.size());
subscription = subscriptionList.get(0);
assertFalse(firstSubscriptionId.equals(subscription.getId()));
// then: we can trigger the second event subscription
runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
// expect: no event subscription left
assertEquals(0, getEventSubscriptionList().size());
// expect: one user task is created
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
// expect: this ends the process instance
assertProcessEnded(processInstance.getId());
}
Aggregations