Search in sources :

Example 26 with EventSubscriptionQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 27 with EventSubscriptionQuery

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 28 with EventSubscriptionQuery

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 29 with EventSubscriptionQuery

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());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery)

Example 30 with EventSubscriptionQuery

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);
}
Also used : EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery)

Aggregations

EventSubscriptionQuery (org.camunda.bpm.engine.runtime.EventSubscriptionQuery)32 EventSubscription (org.camunda.bpm.engine.runtime.EventSubscription)13 Task (org.camunda.bpm.engine.task.Task)8 Deployment (org.camunda.bpm.engine.test.Deployment)8 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)2 Date (java.util.Date)1 HistoricActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1