Package org.camunda.bpm.engine.runtime

Examples of org.camunda.bpm.engine.runtime.ProcessInstance


  }

  @Deployment
  public void testCompensateMiSubprocess() {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");

    assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookHotel"));

    runtimeService.signal(processInstance.getId());
    assertProcessEnded(processInstance.getId());

  }
View Full Code Here


  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.singleReceiveTask.bpmn20.xml")
  public void testSupportsCorrelateMessageOnSingleReceiveTask() {

    // given: a process instance waiting in the receive task
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

    // expect: there is a message event subscription for the task
    List<EventSubscription> subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    EventSubscription subscription = subscriptionList.get(0);

    // then: we can correlate the event subscription
    runtimeService.correlateMessage(subscription.getEventName());

    // expect: subscription is removed
    assertEquals(0, getEventSubscriptionList().size());

    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
  }
View Full Code Here

  }

  @Deployment
  public void testCompensateScope() {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");

    assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookHotel"));
    assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookFlight"));

    runtimeService.signal(processInstance.getId());
    assertProcessEnded(processInstance.getId());

  }
View Full Code Here

  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.singleReceiveTask.bpmn20.xml")
  public void testSupportsCorrelateMessageByBusinessKeyOnSingleReceiveTask() {

    // given: a process instance with business key 23 waiting in the receive task
    ProcessInstance processInstance23 = runtimeService.startProcessInstanceByKey("testProcess", "23");

    // given: a 2nd process instance with business key 42 waiting in the receive task
    ProcessInstance processInstance42 = runtimeService.startProcessInstanceByKey("testProcess", "42");

    // expect: there is two message event subscriptions for the tasks
    List<EventSubscription> subscriptionList = getEventSubscriptionList();
    assertEquals(2, subscriptionList.size());

    // then: we can correlate the event subscription to one of the process instances
    runtimeService.correlateMessage("newInvoiceMessage", "23");

    // expect: one subscription is removed
    assertEquals(1, getEventSubscriptionList().size());

    // expect: this ends the process instance with business key 23
    assertProcessEnded(processInstance23.getId());

    // expect: other process instance is still running
    assertEquals(1, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance42.getId()).count());

    // then: we can correlate the event subscription to the other process instance
    runtimeService.correlateMessage("newInvoiceMessage", "42");

    // expect: subscription is removed
    assertEquals(0, getEventSubscriptionList().size());

    // expect: this ends the process instance
    assertProcessEnded(processInstance42.getId());
  }
View Full Code Here

  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
  public void testSupportsLegacySignalingOnSequentialMultiReceiveTask() {

    // given: a process instance waiting in the first receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

    // expect: there is a message event subscription for the first task
    List<EventSubscription> subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    EventSubscription subscription = subscriptionList.get(0);
    String firstSubscriptionId = subscription.getId();

    // then: we can signal the waiting receive task
    runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));

    // expect: there is a new subscription created for the second receive task instance
    subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    subscription = subscriptionList.get(0);
    assertFalse(firstSubscriptionId.equals(subscription.getId()));

    // then: we can signal the second waiting receive task
    runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));

    // expect: no event subscription left
    assertEquals(0, getEventSubscriptionList().size());

    // expect: one user task is created
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());

    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
  }
View Full Code Here

  // See: https://app.camunda.com/jira/browse/CAM-1410
  @Deployment
  public void testCompensateActivityRef() {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");

    assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookHotel"));
    assertNull(runtimeService.getVariable(processInstance.getId(), "undoBookFlight"));

    runtimeService.signal(processInstance.getId());
    assertProcessEnded(processInstance.getId());

  }
View Full Code Here

  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
  public void testSupportsMessageEventReceivedOnSequentialMultiReceiveTask() {

    // given: a process instance waiting in the first receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

    // expect: there is a message event subscription for the first task
    List<EventSubscription> subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    EventSubscription subscription = subscriptionList.get(0);
    String firstSubscriptionId = subscription.getId();

    // then: we can trigger the event subscription
    runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());

    // expect: there is a new subscription created for the second receive task instance
    subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    subscription = subscriptionList.get(0);
    assertFalse(firstSubscriptionId.equals(subscription.getId()));

    // then: we can trigger the second event subscription
    runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());

    // expect: no event subscription left
    assertEquals(0, getEventSubscriptionList().size());

    // expect: one user task is created
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());

    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
  }
View Full Code Here

          "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCallActivityCompensationHandler.bpmn20.xml",
          "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensationHandler.bpmn20.xml"
  })
  public void testCallActivityCompensationHandler() {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");

    if(!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) {
      assertEquals(5, historyService.createHistoricActivityInstanceQuery()
              .activityId("undoBookHotel")
              .count());
    }

    runtimeService.signal(processInstance.getId());
    assertProcessEnded(processInstance.getId());

    assertEquals(0, runtimeService.createProcessInstanceQuery().count());

    if(!processEngineConfiguration.getHistory().equals(ProcessEngineConfiguration.HISTORY_NONE)) {
      assertEquals(6, historyService.createHistoricProcessInstanceQuery()
View Full Code Here

  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
  public void testSupportsCorrelateMessageOnSequentialMultiReceiveTask() {

    // given: a process instance waiting in the first receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

    // expect: there is a message event subscription for the first task
    List<EventSubscription> subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    EventSubscription subscription = subscriptionList.get(0);
    String firstSubscriptionId = subscription.getId();

    // then: we can trigger the event subscription
    runtimeService.correlateMessage(subscription.getEventName());

    // expect: there is a new subscription created for the second receive task instance
    subscriptionList = getEventSubscriptionList();
    assertEquals(1, subscriptionList.size());
    subscription = subscriptionList.get(0);
    assertFalse(firstSubscriptionId.equals(subscription.getId()));

    // then: we can trigger the second event subscription
    runtimeService.correlateMessage(subscription.getEventName());

    // expect: no event subscription left
    assertEquals(0, getEventSubscriptionList().size());

    // expect: one user task is created
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());

    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
  }
View Full Code Here

  @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml")
  public void testSupportsLegacySignalingOnParallelMultiReceiveTask() {

    // given: a process instance waiting in two receive tasks
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

    // expect: there are two message event subscriptions
    List<EventSubscription> subscriptions = getEventSubscriptionList();
    assertEquals(2, subscriptions.size());

    // expect: there are two executions
    List<Execution> executions = runtimeService.createExecutionQuery()
        .processInstanceId(processInstance.getId()).activityId("waitState")
        .messageEventSubscriptionName("newInvoiceMessage").list();
    assertEquals(2, executions.size());

    // then: we can signal both waiting receive task
    runtimeService.signal(executions.get(0).getId());
    runtimeService.signal(executions.get(1).getId());

    // expect: both event subscriptions are removed
    assertEquals(0, getEventSubscriptionList().size());

    // expect: this ends the process instance
    assertProcessEnded(processInstance.getId());
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.runtime.ProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.