use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceMessageEvent.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricActivityInstanceTest.testHistoricActivityInstanceTimerEvent.bpmn20.xml" })
public void testHistoricActivityInstanceMessageEvent() {
runtimeService.startProcessInstanceByKey("catchSignal");
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
assertEquals(1, eventSubscriptionQuery.count());
runtimeService.correlateMessage("newInvoice");
TaskQuery taskQuery = taskService.createTaskQuery();
Task task = taskQuery.singleResult();
assertEquals("afterMessage", task.getName());
HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("gw1");
assertEquals(1, historicActivityInstanceQuery.count());
assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("messageEvent");
assertEquals(1, historicActivityInstanceQuery.count());
assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
assertEquals("intermediateMessageCatch", historicActivityInstanceQuery.singleResult().getActivityType());
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class EventBasedGatewayTest method testCatchSignalAndMessageAndTimer.
@Deployment
public void testCatchSignalAndMessageAndTimer() {
runtimeService.startProcessInstanceByKey("catchSignal");
assertEquals(2, runtimeService.createEventSubscriptionQuery().count());
EventSubscriptionQuery messageEventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().eventType("message");
assertEquals(1, messageEventSubscriptionQuery.count());
assertEquals(1, runtimeService.createEventSubscriptionQuery().eventType("signal").count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(1, managementService.createJobQuery().count());
// we can query for an execution with has both a signal AND message subscription
Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("newInvoice").signalEventSubscriptionName("alert").singleResult();
assertNotNull(execution);
ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 10000));
try {
EventSubscription messageEventSubscription = messageEventSubscriptionQuery.singleResult();
runtimeService.messageEventReceived(messageEventSubscription.getEventName(), messageEventSubscription.getExecutionId());
assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(0, managementService.createJobQuery().count());
Task task = taskService.createTaskQuery().taskName("afterMessage").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
} finally {
ClockUtil.setCurrentTime(new Date());
}
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testGetNonExistingMessageEventSubscription.
@Test
public void testGetNonExistingMessageEventSubscription() {
EventSubscriptionQuery sampleEventSubscriptionQuery = mock(EventSubscriptionQuery.class);
when(runtimeServiceMock.createEventSubscriptionQuery()).thenReturn(sampleEventSubscriptionQuery);
when(sampleEventSubscriptionQuery.executionId(anyString())).thenReturn(sampleEventSubscriptionQuery);
when(sampleEventSubscriptionQuery.eventName(anyString())).thenReturn(sampleEventSubscriptionQuery);
when(sampleEventSubscriptionQuery.eventType(anyString())).thenReturn(sampleEventSubscriptionQuery);
when(sampleEventSubscriptionQuery.singleResult()).thenReturn(null);
String executionId = MockProvider.EXAMPLE_EXECUTION_ID;
String nonExistingMessageName = "aMessage";
given().pathParam("id", executionId).pathParam("messageName", nonExistingMessageName).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Message event subscription for execution " + executionId + " named " + nonExistingMessageName + " does not exist")).when().get(MESSAGE_SUBSCRIPTION_URL);
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyEventSubscriptionQueryTest method testQueryByTenantIds.
public void testQueryByTenantIds() {
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().tenantIdIn(TENANT_ONE, TENANT_TWO);
assertThat(query.count(), is(2L));
}
use of org.camunda.bpm.engine.runtime.EventSubscriptionQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyEventSubscriptionQueryTest method testQueryDisabledTenantCheck.
public void testQueryDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
assertThat(query.count(), is(3L));
}
Aggregations