use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class BoundaryErrorEventTest method testCatchErrorOnSubprocessThrownByNonInterruptingEventSubprocess.
@Deployment
public void testCatchErrorOnSubprocessThrownByNonInterruptingEventSubprocess() {
runtimeService.startProcessInstanceByKey("testProcess");
EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
runtimeService.messageEventReceived("message", messageSubscription.getExecutionId());
// should successfully have reached the task following the boundary event
Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult();
assertNotNull(taskExecution);
Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult();
assertNotNull(task);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class BoundaryErrorEventTest method testCatchErrorOnSubprocessThrownByNestedEventSubprocess.
@Deployment
public void testCatchErrorOnSubprocessThrownByNestedEventSubprocess() {
runtimeService.startProcessInstanceByKey("testProcess");
// trigger outer event subprocess
EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
runtimeService.messageEventReceived("outerMessage", messageSubscription.getExecutionId());
// trigger inner event subprocess
messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
runtimeService.messageEventReceived("innerMessage", messageSubscription.getExecutionId());
// should successfully have reached the task following the boundary event
Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult();
assertNotNull(taskExecution);
Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult();
assertNotNull(task);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class CompensateEventTest method FAILING_testReceiveTaskCompensationHandler.
/**
* CAM-4387
*/
@Deployment
public void FAILING_testReceiveTaskCompensationHandler() {
// given a process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("receiveTaskCompensationHandler");
// when triggering compensation
Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
taskService.complete(beforeCompensationTask.getId());
// then there is a message event subscription for the receive task compensation handler
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(eventSubscription);
assertEquals(EventType.MESSAGE, eventSubscription.getEventType());
// and triggering the message completes compensation
runtimeService.correlateMessage("Message");
Task afterCompensationTask = taskService.createTaskQuery().singleResult();
assertNotNull(afterCompensationTask);
assertEquals("beforeEnd", afterCompensationTask.getTaskDefinitionKey());
taskService.complete(afterCompensationTask.getId());
// and the process has successfully ended
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class InterruptingEventSubProcessTest method testCancelEventSubscriptionsWhenReceivingASignal.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/subprocess/InterruptingEventSubProcessTest.testCancelEventSubscriptions.bpmn")
public void testCancelEventSubscriptionsWhenReceivingASignal() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
TaskQuery taskQuery = taskService.createTaskQuery();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskBeforeInterruptingEventSuprocess", task.getTaskDefinitionKey());
List<EventSubscription> eventSubscriptions = eventSubscriptionQuery.list();
assertEquals(2, eventSubscriptions.size());
runtimeService.signalEventReceived("newSignal", pi.getId());
task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("tastAfterSignalStartEvent", task.getTaskDefinitionKey());
assertEquals(0, eventSubscriptionQuery.count());
try {
runtimeService.messageEventReceived("newMessage", pi.getId());
fail("A ProcessEngineException was expected.");
} catch (ProcessEngineException e) {
// expected exception;
}
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class InterruptingEventSubProcessTest method testKeepCompensation.
@Deployment
public void testKeepCompensation() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
TaskQuery taskQuery = taskService.createTaskQuery();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskBeforeInterruptingEventSuprocess", task.getTaskDefinitionKey());
List<EventSubscription> eventSubscriptions = eventSubscriptionQuery.list();
assertEquals(2, eventSubscriptions.size());
runtimeService.messageEventReceived("newMessage", pi.getId());
task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskAfterMessageStartEvent", task.getTaskDefinitionKey());
assertEquals(1, eventSubscriptionQuery.count());
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
Aggregations