Search in sources :

Example 16 with EventSubscription

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

the class BoundaryErrorEventTest method testCatchErrorOnSubprocessThrownByInterruptingEventSubprocess.

@Deployment
public void testCatchErrorOnSubprocessThrownByInterruptingEventSubprocess() {
    runtimeService.startProcessInstanceByKey("testProcess");
    EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
    runtimeService.messageEventReceived("message", messageSubscription.getExecutionId());
    // should successfully have reached the task following the boundary event
    Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult();
    assertNotNull(taskExecution);
    Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult();
    assertNotNull(task);
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with EventSubscription

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

the class ProcessInstanceModificationEventTest method testStartBeforeMessageStartEvent.

@Deployment(resources = MESSAGE_START_EVENT_PROCESS)
public void testStartBeforeMessageStartEvent() {
    runtimeService.correlateMessage("startMessage");
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    assertNotNull(processInstance);
    EventSubscription startEventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
    assertNotNull(startEventSubscription);
    String processInstanceId = processInstance.getId();
    // when I start before the message start event
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute();
    // then there are two instances of "task"
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task").activity("task").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child("task").concurrent().noScope().done());
    // and there is only the message start event subscription
    EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
    assertNotNull(subscription);
    assertEquals(startEventSubscription.getId(), subscription.getId());
    completeTasksInOrder("task", "task");
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) 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 18 with EventSubscription

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

the class EventSubscriptionQueryTest method testQueryByEventSubscriptionId.

public void testQueryByEventSubscriptionId() {
    createExampleEventSubscriptions();
    List<EventSubscription> list = runtimeService.createEventSubscriptionQuery().eventName("messageName2").list();
    assertEquals(1, list.size());
    EventSubscription eventSubscription = list.get(0);
    EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().eventSubscriptionId(eventSubscription.getId());
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    assertNotNull(query.singleResult());
    try {
        runtimeService.createEventSubscriptionQuery().eventSubscriptionId(null).list();
        fail("Expected ProcessEngineException");
    } catch (ProcessEngineException e) {
    }
    cleanDb();
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) EventSubscriptionQuery(org.camunda.bpm.engine.runtime.EventSubscriptionQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 19 with EventSubscription

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

the class EventSubscriptionQueryTest method testMultipleEventSubscriptions.

@Deployment
public void testMultipleEventSubscriptions() {
    String message = "cancelation-requested";
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
    assertTrue(areJobsAvailable());
    long eventSubscriptionCount = runtimeService.createEventSubscriptionQuery().count();
    assertEquals(2, eventSubscriptionCount);
    EventSubscription messageEvent = runtimeService.createEventSubscriptionQuery().eventType("message").singleResult();
    assertEquals(message, messageEvent.getEventName());
    EventSubscription compensationEvent = runtimeService.createEventSubscriptionQuery().eventType("compensate").singleResult();
    assertNull(compensationEvent.getEventName());
    runtimeService.createMessageCorrelation(message).processInstanceId(processInstance.getId()).correlate();
    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 20 with EventSubscription

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

the class BatchMigrationTest method testUpdateEventTrigger.

@Test
public void testUpdateEventTrigger() {
    // given
    String newMessageName = "newMessage";
    ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_RECEIVE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.ONE_RECEIVE_TASK_PROCESS).renameMessage("Message", newMessageName));
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().updateEventTriggers().build();
    Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance.getId())).executeAsync();
    helper.executeSeedJob(batch);
    // when
    helper.executeJobs(batch);
    // then the message event subscription's event name was changed
    EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
    assertEquals(newMessageName, eventSubscription.getEventName());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) Batch(org.camunda.bpm.engine.batch.Batch) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

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