use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnParallelMultiReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnParallelMultiReceiveTask() {
// 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 trigger both event subscriptions
runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId());
runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId());
// 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 testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundaryEventReceived.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTaskBoundary.bpmn20.xml")
public void testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundaryEventReceived() {
// given: a process instance waiting in two receive tasks
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there are three message event subscriptions
assertEquals(3, getEventSubscriptionList().size());
// expect: there is one message event subscription for the boundary event
List<EventSubscription> subscriptions = getEventSubscriptionList("cancel");
assertEquals(1, subscriptions.size());
EventSubscription subscription = subscriptions.get(0);
// then: we can trigger the boundary subscription to cancel both tasks
runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
// expect: all subscriptions are removed (receive task subscriptions too)
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 testSupportsLegacySignalingOnSequentialMultiReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
public void testSupportsLegacySignalingOnSequentialMultiReceiveTask() {
// 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 signal the waiting receive task
runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));
// 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 signal the second waiting receive task
runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));
// 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());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundary.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTaskBoundary.bpmn20.xml")
public void testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundary() {
// given: a process instance waiting in two receive tasks
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// expect: there are three message event subscriptions
assertEquals(3, getEventSubscriptionList().size());
// expect: there are two message event subscriptions for the receive tasks
List<EventSubscription> subscriptions = getEventSubscriptionList("waitState");
assertEquals(2, subscriptions.size());
// then: we can trigger both receive task event subscriptions
runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId());
runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId());
// expect: all subscriptions are removed (boundary subscription is removed too)
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 EventBasedGatewayTest method testCatchSignalAndMessageAndTimer.
@Deployment
public void testCatchSignalAndMessageAndTimer() {
runtimeService.startProcessInstanceByKey("catchSignal");
assertEquals(2, runtimeService.createEventSubscriptionQuery().count());
EventSubscriptionQuery messageEventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().eventType("message");
assertEquals(1, messageEventSubscriptionQuery.count());
assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("signal").count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(1, managementService.createJobQuery().count());
// we can query for an execution with has both a signal AND message subscription
Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("newInvoice").signalEventSubscriptionName("alert").singleResult();
assertNotNull(execution);
ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 10000));
try {
EventSubscription messageEventSubscription = messageEventSubscriptionQuery.singleResult();
runtimeService.messageEventReceived(messageEventSubscription.getEventName(), messageEventSubscription.getExecutionId());
assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(0, managementService.createJobQuery().count());
Task task = taskService.createTaskQuery().taskName("afterMessage").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
} finally {
ClockUtil.setCurrentTime(new Date());
}
}
Aggregations