Search in sources :

Example 66 with EventSubscription

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

the class ReceiveTaskTest method testSupportsMessageEventReceivedOnMultiSubProcessReceiveTask.

@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSubProcessReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnMultiSubProcessReceiveTask() {
    // given: a process instance waiting in two parallel sub-process receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
    // expect: there are two message event subscriptions
    List<EventSubscription> subscriptions = getEventSubscriptionList();
    assertEquals(2, subscriptions.size());
    // then: we can trigger both receive task event subscriptions
    runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId());
    runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId());
    // expect: subscriptions are removed
    assertEquals(0, getEventSubscriptionList().size());
    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 67 with EventSubscription

use of org.camunda.bpm.engine.runtime.EventSubscription 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 68 with EventSubscription

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

the class EventSubscriptionAuthorizationTest method testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition.

public void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
    // 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 69 with EventSubscription

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

the class ProcessInstanceModificationCancellationTest method testProcessInstanceEventSubscriptionsPreservedOnIntermediateCancellation.

@Deployment(resources = INTERRUPTING_EVENT_SUBPROCESS)
public void testProcessInstanceEventSubscriptionsPreservedOnIntermediateCancellation() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    // event subscription for the event subprocess
    EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
    assertNotNull(subscription);
    assertEquals(processInstance.getId(), subscription.getProcessInstanceId());
    // when I execute cancellation and then start, such that the intermediate state of the process instance
    // has no activities
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).startBeforeActivity("task1").execute();
    // then the message event subscription remains (i.e. it is not deleted and later re-created)
    EventSubscription updatedSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
    assertNotNull(updatedSubscription);
    assertEquals(subscription.getId(), updatedSubscription.getId());
    assertEquals(subscription.getProcessInstanceId(), updatedSubscription.getProcessInstanceId());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 70 with EventSubscription

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

the class ExecutionQueryTest method testQueryForExecutionsWithMultipleSubscriptions.

@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/twoBoundaryEventSubscriptions.bpmn20.xml")
public void testQueryForExecutionsWithMultipleSubscriptions() {
    // given two message event subscriptions
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    List<EventSubscription> subscriptions = runtimeService.createEventSubscriptionQuery().processInstanceId(instance.getId()).list();
    assertEquals(2, subscriptions.size());
    assertEquals(subscriptions.get(0).getExecutionId(), subscriptions.get(1).getExecutionId());
    // should return the execution once (not twice)
    Execution execution = runtimeService.createExecutionQuery().messageEventSubscription().singleResult();
    assertNotNull(execution);
    assertEquals(instance.getId(), execution.getProcessInstanceId());
    // should return the execution once
    execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").singleResult();
    assertNotNull(execution);
    assertEquals(instance.getId(), execution.getProcessInstanceId());
    // should return the execution once
    execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_2").singleResult();
    assertNotNull(execution);
    assertEquals(instance.getId(), execution.getProcessInstanceId());
    // should return the execution once
    execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").messageEventSubscriptionName("messageName_2").singleResult();
    assertNotNull(execution);
    assertEquals(instance.getId(), execution.getProcessInstanceId());
    // should not return the execution
    execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName_1").messageEventSubscriptionName("messageName_2").messageEventSubscriptionName("another").singleResult();
    assertNull(execution);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

EventSubscription (org.camunda.bpm.engine.runtime.EventSubscription)71 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)38 Deployment (org.camunda.bpm.engine.test.Deployment)38 Task (org.camunda.bpm.engine.task.Task)16 EventSubscriptionQuery (org.camunda.bpm.engine.runtime.EventSubscriptionQuery)13 Test (org.junit.Test)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)10 Execution (org.camunda.bpm.engine.runtime.Execution)8 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)6 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)4 HashMap (java.util.HashMap)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1