use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyEventSubscriptionQueryTest method testQueryByNonExistingTenantId.
public void testQueryByNonExistingTenantId() {
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().tenantIdIn("nonExisting");
assertThat(query.count(), is(0L));
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class CallActivityTest method testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml" })
public void testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the message interrupting event sub process
runtimeService.correlateMessage("newMessage");
Task taskAfterMessageStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterMessageStartEvent", taskAfterMessageStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterMessageStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class CallActivityTest method testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml" })
public void testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the signal interrupting event sub process
runtimeService.signalEventReceived("newSignal");
Task taskAfterSignalStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterSignalStartEvent", taskAfterSignalStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterSignalStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class EventSubscriptionQueryTest method testQueryByEventSubscriptionId.
public void testQueryByEventSubscriptionId() {
createExampleEventSubscriptions();
List<EventSubscription> list = runtimeService.createEventSubscriptionQuery().eventName("messageName2").list();
assertEquals(1, list.size());
EventSubscription eventSubscription = list.get(0);
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().eventSubscriptionId(eventSubscription.getId());
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
try {
runtimeService.createEventSubscriptionQuery().eventSubscriptionId(null).list();
fail("Expected ProcessEngineException");
} catch (ProcessEngineException e) {
}
cleanDb();
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class InterruptingEventSubProcessTest method testCancelEventSubscriptionsWhenReceivingAMessage.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/subprocess/InterruptingEventSubProcessTest.testCancelEventSubscriptions.bpmn")
public void testCancelEventSubscriptionsWhenReceivingAMessage() {
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(0, eventSubscriptionQuery.count());
try {
runtimeService.signalEventReceived("newSignal", pi.getId());
fail("A ProcessEngineException was expected.");
} catch (ProcessEngineException e) {
// expected exception;
}
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
Aggregations