Exemple #1
0
        public virtual void testCallBpmnProcessParallelMultiInstance()
        {
            // given
            IBpmnModelInstance model =
                ModifiableBpmnModelInstance.Modify(CallActivityModels.oneBpmnCallActivityProcess("oneTaskProcess"))
                //.ActivityBuilder("callActivity")
                //.MultiInstance()
                //.Parallel()
                //.Cardinality("1")
                //.Done()
            ;

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(model);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(model);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("callActivity#multiInstanceBody", "callActivity#multiInstanceBody")
                .MapActivities("callActivity", "callActivity")
                .Build();

            // when
            var processInstance = testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

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

            testHelper.AssertActivityTreeAfterMigration()
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(targetProcessDefinition.Id)
                          .BeginMiBody("callActivity")
                          .Activity("callActivity", testHelper.GetSingleActivityInstanceBeforeMigration("callActivity")
                                    .Id)
                          .Done());

            // and the link between calling and called instance is maintained correctly

            testHelper.AssertSuperExecutionOfProcessInstance(rule.RuntimeService.CreateProcessInstanceQuery()
                                                             ////.SetProcessDefinitionKey("oneTaskProcess")
                                                             .First()
                                                             .Id, testHelper.GetSingleExecutionIdForActivityAfterMigration("callActivity"));

            // and it is possible to complete the called process instance
            testHelper.CompleteTask("userTask");
            // and the calling process instance
            testHelper.CompleteTask("userTask");

            testHelper.AssertProcessEnded(processInstance.Id);
        }