示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent()
        public virtual void testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_TASK_AND_SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaInputParameter("foo", "subProcessValue").done());

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ExecutionTree   executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree task1CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0];
            ExecutionTree task2CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask2")[0];

            runtimeService.setVariableLocal(task1CcExecution.Id, "foo", "task1Value");
            runtimeService.setVariableLocal(task2CcExecution.Id, "foo", "task2Value");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then the io mapping variable was overwritten due to a compacted execution tree
            Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().Count);

            IList <string> values = new List <string>();

            foreach (VariableInstance variable in testHelper.snapshotAfterMigration.getVariables())
            {
                values.Add((string)variable.Value);
            }

            Assert.assertTrue(values.Contains("task1Value"));
            Assert.assertTrue(values.Contains("task2Value"));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope()
        public virtual void testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ExecutionTree   executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree scopeExecution = executionTreeBeforeMigration.getLeafExecutions("userTask")[0];

            runtimeService.setVariableLocal(scopeExecution.Id, "foo", "userTaskScopeValue");
            runtimeService.setVariableLocal(processInstance.Id, "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().Count);

            VariableInstance variable = testHelper.snapshotAfterMigration.getVariables().GetEnumerator().next();

            Assert.assertEquals("userTaskScopeValue", variable.Value);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtConcurrentAndScopeExecutionBecomeNonScope()
        public virtual void testVariableAtConcurrentAndScopeExecutionBecomeNonScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ExecutionTree   executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree scopeExecution      = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0];
            ExecutionTree concurrentExecution = scopeExecution.Parent;

            runtimeService.setVariableLocal(scopeExecution.Id, "foo", 42);
            runtimeService.setVariableLocal(concurrentExecution.Id, "foo", 42);

            // when
            try
            {
                testHelper.migrateProcessInstance(migrationPlan, processInstance);
                Assert.fail("expected exception");
            }
            catch (ProcessEngineException e)
            {
                Assert.assertThat(e.Message, CoreMatchers.containsString("The variable 'foo' exists in both, this scope" + " and concurrent local in the parent scope. Migrating to a non-scope activity would overwrite one of them."));
            }
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionBecomeScope()
        public virtual void testVariableAtConcurrentExecutionBecomeScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_SCOPE_TASKS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ExecutionTree   executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree concurrentExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0];

            runtimeService.setVariableLocal(concurrentExecution.Id, "foo", 42);

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            VariableInstance beforeMigration      = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
            ExecutionTree    userTask1CCExecution = testHelper.snapshotAfterMigration.ExecutionTree.getLeafExecutions("userTask1")[0].Parent;

            Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count);
            testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecution.Id);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope()
        public virtual void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0].Parent;

            runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", 42);

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then
            VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");

            ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.ExecutionTree.getLeafExecutions("userTask1")[0].Parent;

            Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count);
            // for variables at concurrent executions that are parent of a leaf-scope-execution, the activity instance is
            // the activity instance id of the parent activity instance (which is probably a bug)
            testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.Id, processInstance.Id);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariableAtScopeAndConcurrentExecutionAddParentScope()
        public virtual void testVariableAtScopeAndConcurrentExecutionAddParentScope()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0];
            ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2")[0];

            runtimeService.setVariableLocal(processInstance.Id, "foo", "processInstanceValue");
            runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", "task1Value");
            runtimeService.setVariableLocal(userTask2CCExecutionBefore.Id, "foo", "task2Value");

            VariableInstance processScopeVariable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "processInstanceValue").singleResult();
            VariableInstance task1Variable        = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task1Value").singleResult();
            VariableInstance task2Variable        = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task2Value").singleResult();

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then the scope variable instance has been overwritten during compaction (conform to prior behavior);
            // although this is tested here, changing this behavior may be ok in the future
            Assert.assertEquals(3, testHelper.snapshotAfterMigration.getVariables().Count);

            VariableInstance processScopeVariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(processScopeVariable.Id);

            Assert.assertNotNull(processScopeVariableAfterMigration);
            Assert.assertEquals("processInstanceValue", processScopeVariableAfterMigration.Value);

            VariableInstance task1VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task1Variable.Id);

            Assert.assertNotNull(task1VariableAfterMigration);
            Assert.assertEquals("task1Value", task1VariableAfterMigration.Value);

            VariableInstance task2VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task2Variable.Id);

            Assert.assertNotNull(task2VariableAfterMigration);
            Assert.assertEquals("task2Value", task2VariableAfterMigration.Value);
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddScopeWithInputMappingAndVariableOnConcurrentExecutions()
        public virtual void testAddScopeWithInputMappingAndVariableOnConcurrentExecutions()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaInputParameter("foo", "inputOutputValue").done());

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0];
            ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2")[0];

            runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", "customValue");
            runtimeService.setVariableLocal(userTask2CCExecutionBefore.Id, "foo", "customValue");

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then the scope variable instance has been overwritten during compaction (conform to prior behavior);
            // although this is tested here, changing this behavior may be ok in the future
            ICollection <VariableInstance> variables = testHelper.snapshotAfterMigration.getVariables();

            Assert.assertEquals(2, variables.Count);

            foreach (VariableInstance variable in variables)
            {
                Assert.assertEquals("customValue", variable.Value);
            }

            ExecutionTree subProcessExecution = testHelper.snapshotAfterMigration.ExecutionTree.getLeafExecutions("userTask2")[0].Parent;

            Assert.assertNotNull(testHelper.snapshotAfterMigration.getSingleVariable(subProcessExecution.Id, "foo"));
        }
示例#8
0
        public virtual void noHistoryUpdateOnAddScopeMigration()
        {
            // given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);
            ExecutionTree   executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine);

            ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0].Parent;

            runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", 42);

            // when
            testHelper.migrateProcessInstance(migrationPlan, processInstance);

            // then there is still one historic variable instance
            Assert.assertEquals(1, historyService.createHistoricVariableInstanceQuery().count());

            // and no additional historic details
            Assert.assertEquals(1, historyService.createHistoricDetailQuery().count());
        }