Exemple #1
0
        public virtual void testCallCmmnCaseSimpleMigration()
        {
            // given
            var model = CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase");

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

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .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("callActivity")
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("callActivity"))
                     .Done());

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

            // and it is possible to complete the called case instance
            var caseExecution = rule.CaseService.CreateCaseExecutionQuery(c => c.ActivityId == "PI_HumanTask_1")
                                .First();

            testHelper.CompleteTask("PI_HumanTask_1");
            // and the calling process instance
            testHelper.CompleteTask("userTask");

            testHelper.AssertProcessEnded(processInstance.Id);

            // and close the called case instance
            rule.CaseService.WithCaseExecution(caseExecution.CaseInstanceId)
            .Close();
            testHelper.AssertCaseEnded(caseExecution.CaseInstanceId);
        }
Exemple #2
0
        public virtual void testCallCmmnCaseSequentialMultiInstanceRemoveMiBody()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(
                    ModifiableBpmnModelInstance.Modify(CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase"))
                    //.ActivityBuilder("callActivity")
                    //.MultiInstance()
                    //.Sequential()
                    //.Cardinality("1")
                    //.Done()
                    );
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase"));

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .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("callActivity")
                     .Scope()
                     .Done());

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

            // then the link between calling and called instance is maintained correctly
            testHelper.AssertSuperExecutionOfCaseInstance(rule.CaseService.CreateCaseInstanceQuery()
                                                          //.CaseDefinitionKey("oneTaskCase")
                                                          .First()
                                                          .Id, testHelper.GetSingleExecutionIdForActivityAfterMigration("callActivity"));

            // and it is possible to complete the called case instance
            var caseExecution = rule.CaseService.CreateCaseExecutionQuery(c => c.ActivityId == "PI_HumanTask_1")
                                .First();

            testHelper.CompleteTask("PI_HumanTask_1");

            // and the calling process instance
            testHelper.CompleteTask("userTask");

            testHelper.AssertProcessEnded(processInstance.Id);

            // and close the called case instance
            rule.CaseService.WithCaseExecution(caseExecution.CaseInstanceId)
            .Close();
            testHelper.AssertCaseEnded(caseExecution.CaseInstanceId);
        }