public virtual void testVariablesInParentEventScopeStillAccessible()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(CompensationModels.DOUBLE_SUBPROCESS_MODEL);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("subProcess", "outerSubProcess")
                .MapActivities("compensationBoundary", "compensationBoundary")
                .MapActivities("userTask2", "userTask2")
                .Build();

            var processInstance = rule.RuntimeService.StartProcessInstanceById(sourceProcessDefinition.Id);

            var subProcessExecution = rule.RuntimeService.CreateExecutionQuery(c => c.ActivityId == "userTask1")
                                      .First();

            rule.RuntimeService.SetVariableLocal(subProcessExecution.Id, "foo", "bar");

            testHelper.CompleteTask("userTask1");

            testHelper.MigrateProcessInstance(migrationPlan, processInstance);

            // when throwing compensation
            testHelper.CompleteAnyTask("userTask2");

            // then the variable snapshot is available
            var compensationTask = rule.TaskService.CreateTaskQuery()
                                   .First();

            Assert.AreEqual("bar", rule.TaskService.GetVariable(compensationTask.Id, "foo"));
        }
Exemplo n.º 2
0
        public virtual void testMigrateParallelMultiInstancePartiallyComplete()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(miBodyOf("userTask"), miBodyOf("userTask"))
                .MapActivities("userTask", "userTask")
                .Build();

            // when
            var processInstance = rule.RuntimeService.StartProcessInstanceById(sourceProcessDefinition.Id);

            testHelper.CompleteAnyTask("userTask");
            testHelper.MigrateProcessInstance(migrationPlan, processInstance);

            // then
            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Child(null)
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration(miBodyOf("userTask")))
                     .Child("userTask")
                     .Concurrent()
                     .NoScope()
                     .Up()
                     .Child("userTask")
                     .Concurrent()
                     .NoScope()
                     .Up()
                     .Child("userTask")
                     .Concurrent()
                     .NoScope()
                     .Up()
                     .Done());

            var userTaskInstances = testHelper.SnapshotBeforeMigration.ActivityTree.GetActivityInstances("userTask");

            testHelper.AssertActivityTreeAfterMigration()
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(targetProcessDefinition.Id)
                          .BeginMiBody("userTask", testHelper.GetSingleActivityInstanceBeforeMigration(miBodyOf("userTask"))
                                       .Id)
                          .Activity("userTask", userTaskInstances[0].Id)
                          .Activity("userTask", userTaskInstances[1].Id)
                          .Transition("userTask")
                          .Done()); // bug CAM-5609

            var migratedTasks = testHelper.SnapshotAfterMigration.Tasks;

            Assert.AreEqual(2, migratedTasks.Count);
            foreach (var migratedTask in migratedTasks)
            {
                Assert.AreEqual(targetProcessDefinition.Id, migratedTask.ProcessDefinitionId);
            }

            // and it is possible to successfully complete the migrated instance
            foreach (var migratedTask in migratedTasks)
            {
                rule.TaskService.Complete(migratedTask.Id);
            }
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }