use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MockProvider method createMockEventSubscription.
public static EventSubscription createMockEventSubscription() {
EventSubscription mock = mock(EventSubscription.class);
when(mock.getId()).thenReturn(EXAMPLE_EVENT_SUBSCRIPTION_ID);
when(mock.getEventType()).thenReturn(EXAMPLE_EVENT_SUBSCRIPTION_TYPE);
when(mock.getEventName()).thenReturn(EXAMPLE_EVENT_SUBSCRIPTION_NAME);
when(mock.getExecutionId()).thenReturn(EXAMPLE_EXECUTION_ID);
when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
when(mock.getActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
when(mock.getCreated()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_EVENT_SUBSCRIPTION_CREATION_DATE));
when(mock.getTenantId()).thenReturn(EXAMPLE_TENANT_ID);
return mock;
}
use of org.camunda.bpm.engine.runtime.EventSubscription 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);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MessageEventSubscriptionResource method getEventSubscription.
@Override
public EventSubscriptionDto getEventSubscription() {
RuntimeService runtimeService = engine.getRuntimeService();
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().executionId(executionId).eventName(messageName).eventType(MESSAGE_EVENT_TYPE).singleResult();
if (eventSubscription == null) {
String errorMessage = String.format("Message event subscription for execution %s named %s does not exist", executionId, messageName);
throw new InvalidRequestException(Status.NOT_FOUND, errorMessage);
}
return EventSubscriptionDto.fromEventSubscription(eventSubscription);
}
use of org.camunda.bpm.engine.runtime.EventSubscription 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());
}
use of org.camunda.bpm.engine.runtime.EventSubscription 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());
}
Aggregations