Search in sources :

Example 86 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MessageEventSubprocessTest method testNonInterruptingWithParallelForkInsideEmbeddedSubProcess.

@Deployment
public void testNonInterruptingWithParallelForkInsideEmbeddedSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    runtimeService.messageEventReceived("newMessage", runtimeService.createEventSubscriptionQuery().singleResult().getExecutionId());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("firstUserTask").concurrent().noScope().up().child("secondUserTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").done());
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    assertProcessEnded(processInstance.getId());
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) Task(org.camunda.bpm.engine.task.Task) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 87 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MessageEventSubprocessTest method testMultipleNonInterruptingInEmbeddedSubprocess.

@Deployment
public void testMultipleNonInterruptingInEmbeddedSubprocess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    // the process instance must have a message event subscription:
    Execution subProcess = runtimeService.createExecutionQuery().messageEventSubscriptionName("newMessage").singleResult();
    assertNotNull(subProcess);
    assertEquals(1, createEventSubscriptionQuery().count());
    Task subProcessTask = taskService.createTaskQuery().taskDefinitionKey("subProcessTask").singleResult();
    assertNotNull(subProcessTask);
    // start event sub process multiple times
    for (int i = 1; i < 3; i++) {
        runtimeService.messageEventReceived("newMessage", subProcess.getId());
        // check that now i event sub process tasks exist
        List<Task> eventSubProcessTasks = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").list();
        assertEquals(i, eventSubProcessTasks.size());
    }
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    // check that the parent execution of the event sub process task execution is the event
    // sub process execution
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("subProcessTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().up().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
    // complete sub process task
    taskService.complete(subProcessTask.getId());
    // after complete the sub process task all task should be deleted because of the terminating end event
    assertEquals(0, taskService.createTaskQuery().count());
    // and the process instance should be ended
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 88 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MessageNonInterruptingBoundaryEventTest method testNonInterruptingEventInCombinationWithUserTask.

@Deployment
public void testNonInterruptingEventInCombinationWithUserTask() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when (1)
    runtimeService.correlateMessage("firstMessage");
    // then (1)
    assertEquals(2, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Task innerTask = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult();
    assertNotNull(innerTask);
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").noScope().concurrent().up().child(null).noScope().concurrent().child("innerTask").scope().done());
    // when (2)
    taskService.complete(innerTask.getId());
    // then (2)
    assertEquals(2, taskService.createTaskQuery().count());
    task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    assertNotNull(task2);
    executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").noScope().concurrent().up().child("task2").noScope().concurrent().done());
    assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 89 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class CompensateEventTest method testConcurrentExecutionsAndPendingCompensation.

@Deployment
public void testConcurrentExecutionsAndPendingCompensation() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = instance.getId();
    String taskId = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult().getId();
    // when (1)
    taskService.complete(taskId);
    // then (1)
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().up().child("subProcess").eventScope().scope().up().done());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
    // when (2)
    taskId = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult().getId();
    taskService.complete(taskId);
    // then (2)
    executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree("task2").scope().child("subProcess").eventScope().scope().up().done());
    tree = runtimeService.getActivityInstance(processInstanceId);
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task2").done());
    // when (3)
    taskId = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult().getId();
    taskService.complete(taskId);
    // then (3)
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationTest method testScopeTaskStartBefore.

@Deployment(resources = ONE_SCOPE_TASK_PROCESS)
public void testScopeTaskStartBefore() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    String processInstanceId = processInstance.getId();
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("theTask").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").activity("theTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child("theTask").scope().up().up().child(null).concurrent().noScope().child("theTask").scope().done());
    assertEquals(2, taskService.createTaskQuery().count());
    completeTasksInOrder("theTask", "theTask");
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)155 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)149 Deployment (org.camunda.bpm.engine.test.Deployment)134 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)134 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)130 Task (org.camunda.bpm.engine.task.Task)40 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)20 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)20 Test (org.junit.Test)20 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)17 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 Execution (org.camunda.bpm.engine.runtime.Execution)9 Job (org.camunda.bpm.engine.runtime.Job)6 TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 RecorderExecutionListener (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener)2 RecordedEvent (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent)2 ArrayList (java.util.ArrayList)1 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)1