Search in sources :

Example 46 with ExecutionTree

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

the class ProcessInstanceModificationMultiInstanceTest method testCancelInnerActivityParallelTasks.

@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testCancelInnerActivityParallelTasks() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    completeTasksInOrder("beforeTask");
    // when
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[0].getId()).execute();
    // then
    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miTasks").activity("miTasks").activity("miTasks").endScope().done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().done());
    // and the process is able to complete successfully
    completeTasksInOrder("miTasks", "miTasks", "afterTask");
    assertProcessEnded(processInstance.getId());
}
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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with ExecutionTree

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

the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySequentialSubprocess.

@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySequentialSubprocess() {
    // given the mi body is not yet instantiated
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
    // when
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("subProcessTask").execute();
    // then the mi variables should be correct
    Execution leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
    assertNotNull(leafExecution);
    assertVariable(leafExecution, "loopCounter", 0);
    assertVariable(leafExecution, "nrOfInstances", 1);
    assertVariable(leafExecution, "nrOfCompletedInstances", 0);
    assertVariable(leafExecution, "nrOfActiveInstances", 1);
    // and the trees should be correct
    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("beforeTask").concurrent().noScope().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
    // and the process is able to complete successfully
    completeTasksInOrder("subProcessTask", "afterTask", "beforeTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask");
    assertProcessEnded(processInstance.getId());
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) Execution(org.camunda.bpm.engine.runtime.Execution) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with ExecutionTree

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

the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySetNrOfInstancesSequentialSubprocess.

@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySetNrOfInstancesSequentialSubprocess() {
    // given the mi body is not yet instantiated
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
    // when
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("subProcessTask").setVariable("nrOfInstances", 3).execute();
    // then the mi variables should be correct
    Execution leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
    assertNotNull(leafExecution);
    assertVariable(leafExecution, "loopCounter", 0);
    assertVariable(leafExecution, "nrOfInstances", 3);
    assertVariable(leafExecution, "nrOfCompletedInstances", 0);
    assertVariable(leafExecution, "nrOfActiveInstances", 1);
    // and the trees should be correct
    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("beforeTask").concurrent().noScope().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
    // and two following sequential instances should be created
    completeTasksInOrder("subProcessTask");
    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").done());
    leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
    assertNotNull(leafExecution);
    assertVariable(leafExecution, "loopCounter", 1);
    assertVariable(leafExecution, "nrOfInstances", 3);
    assertVariable(leafExecution, "nrOfCompletedInstances", 1);
    assertVariable(leafExecution, "nrOfActiveInstances", 1);
    completeTasksInOrder("subProcessTask");
    // and the remainder of the process completes successfully
    completeTasksInOrder("subProcessTask", "beforeTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask", "afterTask");
    assertProcessEnded(processInstance.getId());
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) Execution(org.camunda.bpm.engine.runtime.Execution) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with ExecutionTree

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

the class ProcessInstanceModificationMultiInstanceTest method testCancelInnerActivityParallelTasksAllButOne.

/**
 * Ensures that the modification cmd does not prune the last concurrent execution
 * because parallel MI requires this
 */
@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testCancelInnerActivityParallelTasksAllButOne() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    completeTasksInOrder("beforeTask");
    // when
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[0].getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[1].getId()).execute();
    // then
    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miTasks").activity("miTasks").endScope().done());
    // the execution tree should still be in the expected shape
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("miTasks").concurrent().noScope().done());
    // and the process is able to complete successfully
    completeTasksInOrder("miTasks", "afterTask");
    assertProcessEnded(processInstance.getId());
}
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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with ExecutionTree

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

the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeMultiInstanceBodySequentialSubprocess.

@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeMultiInstanceBodySequentialSubprocess() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
    completeTasksInOrder("beforeTask");
    // when
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("miSubProcess#multiInstanceBody").execute();
    // then
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().endScope().beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().up().up().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
    // and the process is able to complete successfully
    completeTasksInOrder("subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask", "afterTask");
    assertProcessEnded(processInstance.getId());
}
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) 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