use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ReceiveTaskTest method testSupportsMessageEventReceivedOnMultiSubProcessReceiveTask.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSubProcessReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnMultiSubProcessReceiveTask() {
// given: a process instance waiting in two parallel sub-process 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 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: 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 EventSubscriptionAuthorizationTest method testSimpleQueryWithReadPermissionOnAnyProcessInstance.
public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
// when
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
// then
verifyQueryResults(query, 1);
EventSubscription eventSubscription = query.singleResult();
assertNotNull(eventSubscription);
assertEquals(processInstanceId, eventSubscription.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class EventSubscriptionAuthorizationTest method testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition.
public void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
// when
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
// then
verifyQueryResults(query, 1);
EventSubscription eventSubscription = query.singleResult();
assertNotNull(eventSubscription);
assertEquals(processInstanceId, eventSubscription.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testProcessInstanceEventSubscriptionsPreservedOnIntermediateCancellation.
@Deployment(resources = INTERRUPTING_EVENT_SUBPROCESS)
public void testProcessInstanceEventSubscriptionsPreservedOnIntermediateCancellation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
// event subscription for the event subprocess
EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(subscription);
assertEquals(processInstance.getId(), subscription.getProcessInstanceId());
// when I execute cancellation and then start, such that the intermediate state of the process instance
// has no activities
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).startBeforeActivity("task1").execute();
// then the message event subscription remains (i.e. it is not deleted and later re-created)
EventSubscription updatedSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(updatedSubscription);
assertEquals(subscription.getId(), updatedSubscription.getId());
assertEquals(subscription.getProcessInstanceId(), updatedSubscription.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testQueryForExecutionsWithMultipleSubscriptions.
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/twoBoundaryEventSubscriptions.bpmn20.xml")
public void testQueryForExecutionsWithMultipleSubscriptions() {
// given two message event subscriptions
ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
List<EventSubscription> subscriptions = runtimeService.createEventSubscriptionQuery().processInstanceId(instance.getId()).list();
assertEquals(2, subscriptions.size());
assertEquals(subscriptions.get(0).getExecutionId(), subscriptions.get(1).getExecutionId());
// should return the execution once (not twice)
Execution execution = runtimeService.createExecutionQuery().messageEventSubscription().singleResult();
assertNotNull(execution);
assertEquals(instance.getId(), execution.getProcessInstanceId());
// should return the execution once
execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").singleResult();
assertNotNull(execution);
assertEquals(instance.getId(), execution.getProcessInstanceId());
// should return the execution once
execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_2").singleResult();
assertNotNull(execution);
assertEquals(instance.getId(), execution.getProcessInstanceId());
// should return the execution once
execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").messageEventSubscriptionName("messageName_2").singleResult();
assertNotNull(execution);
assertEquals(instance.getId(), execution.getProcessInstanceId());
// should not return the execution
execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").messageEventSubscriptionName("messageName_2").messageEventSubscriptionName("another").singleResult();
assertNull(execution);
}
Aggregations