Java Code Examples for org.camunda.bpm.engine.runtime.EventSubscriptionQuery#list()
The following examples show how to use
org.camunda.bpm.engine.runtime.EventSubscriptionQuery#list() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InterruptingEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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()); }
Example 2
Source File: EventSubscriptionRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public List<EventSubscriptionDto> queryEventSubscriptions(EventSubscriptionQueryDto queryDto, Integer firstResult, Integer maxResults) { ProcessEngine engine = getProcessEngine(); queryDto.setObjectMapper(getObjectMapper()); EventSubscriptionQuery query = queryDto.toQuery(engine); List<EventSubscription> matchingEventSubscriptions; if (firstResult != null || maxResults != null) { matchingEventSubscriptions = executePaginatedQuery(query, firstResult, maxResults); } else { matchingEventSubscriptions = query.list(); } List<EventSubscriptionDto> eventSubscriptionResults = new ArrayList<EventSubscriptionDto>(); for (EventSubscription eventSubscription : matchingEventSubscriptions) { EventSubscriptionDto resultEventSubscription = EventSubscriptionDto.fromEventSubscription(eventSubscription); eventSubscriptionResults.add(resultEventSubscription); } return eventSubscriptionResults; }
Example 3
Source File: InterruptingEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }
Example 4
Source File: InterruptingEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }
Example 5
Source File: CallActivityTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }
Example 6
Source File: CallActivityTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }