use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery 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.EventSubscriptionQuery 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());
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class InterruptingEventSubProcessTest method testTimeCycle.
@Deployment
public void testTimeCycle() {
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
assertEquals(0, eventSubscriptionQuery.count());
TaskQuery taskQuery = taskService.createTaskQuery();
assertEquals(1, taskQuery.count());
Task task = taskQuery.singleResult();
assertEquals("task", task.getTaskDefinitionKey());
JobQuery jobQuery = managementService.createJobQuery().timers();
assertEquals(1, jobQuery.count());
String jobId = jobQuery.singleResult().getId();
managementService.executeJob(jobId);
assertEquals(0, jobQuery.count());
assertEquals(1, taskQuery.count());
task = taskQuery.singleResult();
assertEquals("eventSubProcessTask", task.getTaskDefinitionKey());
taskService.complete(task.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery 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.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class EventSubscriptionAuthorizationTest method testQueryWithoutAuthorization.
public void testQueryWithoutAuthorization() {
// given
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
// when
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
// then
verifyQueryResults(query, 0);
}
Aggregations