Search in sources :

Example 1 with EventSubscriptionQuery

use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.

the class ExecutionRestServiceInteractionTest method mockEventSubscriptionQuery.

private void mockEventSubscriptionQuery() {
    EventSubscription mockSubscription = MockProvider.createMockEventSubscription();
    EventSubscriptionQuery mockQuery = mock(EventSubscriptionQuery.class);
    when(runtimeServiceMock.createEventSubscriptionQuery()).thenReturn(mockQuery);
    when(mockQuery.executionId(eq(MockProvider.EXAMPLE_EXECUTION_ID))).thenReturn(mockQuery);
    when(mockQuery.eventType(eq(MockProvider.EXAMPLE_EVENT_SUBSCRIPTION_TYPE))).thenReturn(mockQuery);
    when(mockQuery.eventName(eq(MockProvider.EXAMPLE_EVENT_SUBSCRIPTION_NAME))).thenReturn(mockQuery);
    when(mockQuery.singleResult()).thenReturn(mockSubscription);
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery)

Example 2 with EventSubscriptionQuery

use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.

the class EventSubscriptionAuthorizationTest method testQueryWithReadPermissionOnProcessInstance.

public void testQueryWithReadPermissionOnProcessInstance() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
    startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
    startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
    startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
    startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, 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 3 with EventSubscriptionQuery

use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.

the class EventSubscriptionAuthorizationTest method testSimpleQueryWithoutAuthorization.

public void testSimpleQueryWithoutAuthorization() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    // when
    EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
    // then
    verifyQueryResults(query, 0);
}
Also used : EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery)

Example 4 with EventSubscriptionQuery

use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.

the class EventSubscriptionAuthorizationTest method testSimpleQueryWithReadPermissionOnProcessInstance.

public void testSimpleQueryWithReadPermissionOnProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, 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 5 with EventSubscriptionQuery

use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.

the class EventSubscriptionAuthorizationTest method testSimpleQueryWithMultiple.

public void testSimpleQueryWithMultiple() {
    // given
    String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
    // then
    verifyQueryResults(query, 1);
}
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