Search in sources :

Example 6 with ActivitySequenceCounterMap

use of org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap in project camunda-bpm-platform by camunda.

the class ExecutionSequenceCounterTest method testForkSameSequenceLengthInsideSubProcess.

@Deployment
public void testForkSameSequenceLengthInsideSubProcess() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when
    // then
    assertProcessEnded(processInstanceId);
    List<ActivitySequenceCounterMap> order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(3, order.size());
    ActivitySequenceCounterMap innerEnd1Element = order.get(0);
    assertEquals("innerEnd1", innerEnd1Element.getActivityId());
    ActivitySequenceCounterMap innerEnd2Element = order.get(1);
    assertEquals("innerEnd2", innerEnd2Element.getActivityId());
    ActivitySequenceCounterMap theService1Element = order.get(2);
    assertEquals("theService1", theService1Element.getActivityId());
    assertTrue(theService1Element.getSequenceCounter() > innerEnd1Element.getSequenceCounter());
    assertTrue(theService1Element.getSequenceCounter() > innerEnd2Element.getSequenceCounter());
}
Also used : ActivitySequenceCounterMap(org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with ActivitySequenceCounterMap

use of org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap in project camunda-bpm-platform by camunda.

the class ExecutionSequenceCounterTest method testForkAndJoinThreeBranchesDifferentSequenceLength.

@Deployment
public void testForkAndJoinThreeBranchesDifferentSequenceLength() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when
    // then
    assertProcessEnded(processInstanceId);
    List<ActivitySequenceCounterMap> order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(4, order.size());
    ActivitySequenceCounterMap theJoin1Element = order.get(0);
    assertEquals("join", theJoin1Element.getActivityId());
    ActivitySequenceCounterMap theJoin2Element = order.get(1);
    assertEquals("join", theJoin2Element.getActivityId());
    ActivitySequenceCounterMap theJoin3Element = order.get(2);
    assertEquals("join", theJoin3Element.getActivityId());
    assertFalse(theJoin1Element.getSequenceCounter() == theJoin2Element.getSequenceCounter());
    assertFalse(theJoin2Element.getSequenceCounter() == theJoin3Element.getSequenceCounter());
    assertFalse(theJoin3Element.getSequenceCounter() == theJoin1Element.getSequenceCounter());
    ActivitySequenceCounterMap theService7Element = order.get(3);
    assertEquals("theService7", theService7Element.getActivityId());
    assertTrue(theService7Element.getSequenceCounter() > theJoin1Element.getSequenceCounter());
    assertTrue(theService7Element.getSequenceCounter() > theJoin2Element.getSequenceCounter());
    assertTrue(theService7Element.getSequenceCounter() > theJoin3Element.getSequenceCounter());
}
Also used : ActivitySequenceCounterMap(org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with ActivitySequenceCounterMap

use of org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap in project camunda-bpm-platform by camunda.

the class ExecutionSequenceCounterTest method testForkReplaceByThreeBranches.

@Deployment
public void testForkReplaceByThreeBranches() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    JobQuery jobQuery = managementService.createJobQuery();
    // when (1)
    // then (1)
    List<ActivitySequenceCounterMap> order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(3, order.size());
    ActivitySequenceCounterMap theService1Element = order.get(0);
    assertEquals("theService1", theService1Element.getActivityId());
    ActivitySequenceCounterMap theService3Element = order.get(1);
    assertEquals("theService3", theService3Element.getActivityId());
    ActivitySequenceCounterMap theService6Element = order.get(2);
    assertEquals("theService6", theService6Element.getActivityId());
    assertTrue(theService1Element.getSequenceCounter() == theService3Element.getSequenceCounter());
    assertTrue(theService3Element.getSequenceCounter() == theService6Element.getSequenceCounter());
    // when (2)
    String jobId = jobQuery.activityId("theService2").singleResult().getId();
    managementService.executeJob(jobId);
    // then (2)
    order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(5, order.size());
    ActivitySequenceCounterMap theService2Element = order.get(3);
    assertEquals("theService2", theService2Element.getActivityId());
    assertTrue(theService2Element.getSequenceCounter() > theService1Element.getSequenceCounter());
    ActivitySequenceCounterMap theEnd1Element = order.get(4);
    assertEquals("theEnd1", theEnd1Element.getActivityId());
    assertTrue(theEnd1Element.getSequenceCounter() > theService2Element.getSequenceCounter());
    // when (3)
    jobId = jobQuery.activityId("theService4").singleResult().getId();
    managementService.executeJob(jobId);
    // then (3)
    order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(8, order.size());
    ActivitySequenceCounterMap theService4Element = order.get(5);
    assertEquals("theService4", theService4Element.getActivityId());
    assertTrue(theService4Element.getSequenceCounter() > theService3Element.getSequenceCounter());
    ActivitySequenceCounterMap theService5Element = order.get(6);
    assertEquals("theService5", theService5Element.getActivityId());
    assertTrue(theService5Element.getSequenceCounter() > theService4Element.getSequenceCounter());
    ActivitySequenceCounterMap theEnd2Element = order.get(7);
    assertEquals("theEnd2", theEnd2Element.getActivityId());
    assertTrue(theEnd2Element.getSequenceCounter() > theService5Element.getSequenceCounter());
    // when (4)
    jobId = jobQuery.activityId("theService7").singleResult().getId();
    managementService.executeJob(jobId);
    // then (4)
    order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(12, order.size());
    ActivitySequenceCounterMap theService7Element = order.get(8);
    assertEquals("theService7", theService7Element.getActivityId());
    assertTrue(theService7Element.getSequenceCounter() > theService6Element.getSequenceCounter());
    assertTrue(theService7Element.getSequenceCounter() > theEnd2Element.getSequenceCounter());
    ActivitySequenceCounterMap theService8Element = order.get(9);
    assertEquals("theService8", theService8Element.getActivityId());
    assertTrue(theService8Element.getSequenceCounter() > theService7Element.getSequenceCounter());
    ActivitySequenceCounterMap theService9Element = order.get(10);
    assertEquals("theService9", theService9Element.getActivityId());
    assertTrue(theService9Element.getSequenceCounter() > theService8Element.getSequenceCounter());
    ActivitySequenceCounterMap theEnd3Element = order.get(11);
    assertEquals("theEnd3", theEnd3Element.getActivityId());
    assertTrue(theEnd3Element.getSequenceCounter() > theService9Element.getSequenceCounter());
    assertProcessEnded(processInstanceId);
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ActivitySequenceCounterMap(org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with ActivitySequenceCounterMap

use of org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap in project camunda-bpm-platform by camunda.

the class ExecutionSequenceCounterTest method testNonInterruptingBoundaryEvent.

@Deployment
public void testNonInterruptingBoundaryEvent() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when (1)
    // then (1)
    List<ActivitySequenceCounterMap> order = ExecutionOrderListener.getActivityExecutionOrder();
    verifyOrder(order, "theStart", "theService1", "theTask");
    // when (2)
    runtimeService.correlateMessage("newMessage");
    // then (2)
    order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(6, order.size());
    ActivitySequenceCounterMap theService1Element = order.get(1);
    assertEquals("theService1", theService1Element.getActivityId());
    ActivitySequenceCounterMap theTaskElement = order.get(2);
    assertEquals("theTask", theTaskElement.getActivityId());
    ActivitySequenceCounterMap messageBoundaryElement = order.get(3);
    assertEquals("messageBoundary", messageBoundaryElement.getActivityId());
    assertTrue(messageBoundaryElement.getSequenceCounter() > theService1Element.getSequenceCounter());
    assertFalse(messageBoundaryElement.getSequenceCounter() > theTaskElement.getSequenceCounter());
    ActivitySequenceCounterMap theServiceAfterMessageElement = order.get(4);
    assertEquals("theServiceAfterMessage", theServiceAfterMessageElement.getActivityId());
    assertTrue(theServiceAfterMessageElement.getSequenceCounter() > messageBoundaryElement.getSequenceCounter());
    ActivitySequenceCounterMap theEnd2Element = order.get(5);
    assertEquals("theEnd2", theEnd2Element.getActivityId());
    assertTrue(theEnd2Element.getSequenceCounter() > theServiceAfterMessageElement.getSequenceCounter());
    // when (3)
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    // then (3)
    assertProcessEnded(processInstanceId);
    order = ExecutionOrderListener.getActivityExecutionOrder();
    assertEquals(7, order.size());
    ActivitySequenceCounterMap theEnd1Element = order.get(6);
    assertEquals("theEnd1", theEnd1Element.getActivityId());
    assertTrue(theEnd1Element.getSequenceCounter() > theEnd2Element.getSequenceCounter());
}
Also used : ActivitySequenceCounterMap(org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with ActivitySequenceCounterMap

use of org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap in project camunda-bpm-platform by camunda.

the class ExecutionSequenceCounterTest method verifyOrder.

protected void verifyOrder(List<ActivitySequenceCounterMap> actualOrder, String... expectedOrder) {
    assertEquals(expectedOrder.length, actualOrder.size());
    long lastActualSequenceCounter = 0;
    for (int i = 0; i < expectedOrder.length; i++) {
        ActivitySequenceCounterMap actual = actualOrder.get(i);
        String actualActivityId = actual.getActivityId();
        String expectedActivityId = expectedOrder[i];
        assertEquals(actualActivityId, expectedActivityId);
        long actualSequenceCounter = actual.getSequenceCounter();
        assertTrue(actualSequenceCounter > lastActualSequenceCounter);
        lastActualSequenceCounter = actualSequenceCounter;
    }
}
Also used : ActivitySequenceCounterMap(org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap)

Aggregations

ActivitySequenceCounterMap (org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap)13 Deployment (org.camunda.bpm.engine.test.Deployment)12 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)5