Search in sources :

Example 21 with EventSubscriptionQuery

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

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

Example 23 with EventSubscriptionQuery

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);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery) Test(org.junit.Test)

Example 24 with EventSubscriptionQuery

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

Example 25 with EventSubscriptionQuery

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));
}
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