Search in sources :

Example 66 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtConcurrentExecutionInNonScopeActivityAddParentScope.

@Test
public void testVariableAtConcurrentExecutionInNonScopeActivityAddParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
    runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.getId());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 67 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope.

@Test
public void testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree scopeExecution = executionTreeBeforeMigration.getLeafExecutions("userTask").get(0);
    runtimeService.setVariableLocal(scopeExecution.getId(), "foo", "userTaskScopeValue");
    runtimeService.setVariableLocal(processInstance.getId(), "foo", "processScopeValue");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then the process scope variable was overwritten due to a compacted execution tree
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    VariableInstance variable = testHelper.snapshotAfterMigration.getVariables().iterator().next();
    Assert.assertEquals("userTaskScopeValue", variable.getValue());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 68 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtConcurrentExecutionInScopeActivity.

@Test
public void testVariableAtConcurrentExecutionInScopeActivity() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree concurrentExecution = executionTreeBeforeMigration.getExecutions().get(0);
    runtimeService.setVariableLocal(concurrentExecution.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, beforeMigration.getExecutionId());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 69 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtConcurrentExecutionInNonScopeActivity.

@Test
public void testVariableAtConcurrentExecutionInNonScopeActivity() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree concurrentExecution = executionTreeBeforeMigration.getExecutions().get(0);
    runtimeService.setVariableLocal(concurrentExecution.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, beforeMigration.getExecutionId());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 70 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtConcurrentExecutionInNonScopeActivityRemoveParentScope.

@Test
public void testVariableAtConcurrentExecutionInNonScopeActivityRemoveParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
    runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.getId());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

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