Exemple #1
0
        public virtual void testCannotMigrateHorizontallyBetweenScopes()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.ParallelSubprocessProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.ParallelSubprocessProcess);

            // when
            try
            {
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("subProcess1", "subProcess1")
                .MapActivities("subProcess2", "subProcess2")
                .MapActivities("userTask1", "userTask2")
                .MapActivities("userTask2", "userTask1")
                .Build();

                Assert.Fail("should Assert.Fail");
            }
            catch (MigrationPlanValidationException e)
            {
                MigrationPlanValidationReportAssert.That(e.ValidationReport)
                .HasInstructionFailures("userTask1",
                                        "The closest mapped ancestor 'subProcess1' is mapped to scope 'subProcess1' which is not an ancestor of target scope 'userTask2'")
                .HasInstructionFailures("userTask2",
                                        "The closest mapped ancestor 'subProcess2' is mapped to scope 'subProcess2' which is not an ancestor of target scope 'userTask1'");
            }
        }
        public virtual void testCannotMigrateActivityInstance()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            var model = ProcessModels.NewModel()
                        .StartEvent()
                        .ServiceTask("serviceTask")
                        .CamundaClass(typeof(SignallableServiceTaskDelegate).FullName)
                        .EndEvent()
                        .Done();

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

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

            // when
            try
            {
                testHelper.CreateProcessInstanceAndMigrate(migrationPlan);
                Assert.Fail("should Assert.Fail");
            }
            catch (MigratingProcessInstanceValidationException e)
            {
                // then
                MigratingProcessInstanceValidationReportAssert.That(e.ValidationReport)
                .HasActivityInstanceFailures("serviceTask",
                                             "The type of the source activity is not supported for activity instance migration");
            }
        }
        public virtual void testMigrateCompensationSubscriptionAddRemoveSubProcess()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);

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

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

            testHelper.CompleteTask("userTask1");

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

            // then
            testHelper.AssertEventSubscriptionMigrated("compensationHandler", "compensationHandler", null);

            // and the compensation can be triggered and completed
            testHelper.CompleteTask("userTask2");
            testHelper.CompleteTask("compensationHandler");

            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testMigrateEventSubprocessSignalTrigger()
        {
            var processModel = ProcessModels.OneTaskProcess.Clone();
            var eventTrigger = eventFactory.AddEventSubProcess(rule.ProcessEngine, processModel,
                                                               ProcessModels.ProcessKey, "eventSubProcess", "eventSubProcessStart");

            ModifiableBpmnModelInstance.Wrap(processModel)
            .StartEventBuilder("eventSubProcessStart")
            .UserTask("eventSubProcessTask")
            .EndEvent()
            .Done();

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

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

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

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

            // then
            eventTrigger.AssertEventTriggerMigrated(testHelper, "eventSubProcessStart");

            // and it is possible to trigger the event subprocess
            eventTrigger.Trigger(processInstance.Id);
            Assert.AreEqual(1, rule.TaskService.CreateTaskQuery()
                            .Count());

            // and complete the process instance
            testHelper.CompleteTask("eventSubProcessTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #5
0
        public virtual void testMigrateActiveCompensationEventSubProcess()
        {
            // given
            var processModel = ProcessModels.OneTaskProcess.Clone();
            var eventTrigger = eventFactory.AddEventSubProcess(rule.ProcessEngine, processModel,
                                                               ProcessModels.ProcessKey, "eventSubProcess", "eventSubProcessStart");

            ModifiableBpmnModelInstance.Wrap(processModel)
            .StartEventBuilder("eventSubProcessStart")
            .UserTask("eventSubProcessTask")
            .EndEvent()
            .Done();

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

            IProcessInstance processInstance = rule.RuntimeService.CreateProcessInstanceById(sourceProcessDefinition.Id)
                                               .StartBeforeActivity("eventSubProcessStart")
                                               .ExecuteWithVariablesInReturn();

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("eventSubProcess", "eventSubProcess")
                .MapActivities("eventSubProcessStart", "eventSubProcessStart")
                .UpdateEventTrigger()
                .MapActivities("eventSubProcessTask", "eventSubProcessTask")
                .Build();

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

            // then
            eventTrigger.AssertEventTriggerMigrated(testHelper, "eventSubProcessStart");

            // and it is possible to complete the process instance
            testHelper.CompleteTask("eventSubProcessTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #6
0
        public virtual void testMigrateEventSubscription()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);

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

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

            testHelper.AssertEventSubscriptionMigrated("messageCatch", "messageCatch", MessageReceiveModels.MESSAGE_NAME);

            // and it is possible to trigger the receive task
            rule.RuntimeService.CorrelateMessage(MessageReceiveModels.MESSAGE_NAME);

            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testCannotFlipAncestorScopes()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.DoubleSubprocessProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.DoubleSubprocessProcess);

            // when
            try
            {
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("outerSubProcess", "innerSubProcess")
                .MapActivities("innerSubProcess", "outerSubProcess")
                .MapActivities("userTask", "userTask")
                .Build();

                Assert.Fail("should not validate");
            }
            catch (MigrationPlanValidationException e)
            {
                MigrationPlanValidationReportAssert.That(e.ValidationReport)
                .HasInstructionFailures("innerSubProcess",
                                        "The closest mapped ancestor 'outerSubProcess' is mapped to scope 'innerSubProcess' which is not an ancestor of target scope 'outerSubProcess'");
            }
        }
Exemple #8
0
        public virtual void testAddMultiInstanceBody()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);

            try
            {
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("userTask", "userTask")
                .Build();
                Assert.Fail("Should not succeed");
            }
            catch (MigrationPlanValidationException e)
            {
                MigrationPlanValidationReportAssert.That(e.ValidationReport)
                .HasInstructionFailures("userTask",
                                        "Target activity 'userTask' is a descendant of multi-instance body 'userTask#multiInstanceBody' " +
                                        "that is not mapped from the source process definition");
            }
        }
        public virtual void testMigrateEventSubscription()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ONE_CONDITION_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ONE_CONDITION_PROCESS);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(ConditionalModels.CONDITION_ID, ConditionalModels.CONDITION_ID)
                .UpdateEventTrigger()
                .Build();

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

            testHelper.AssertEventSubscriptionMigrated(ConditionalModels.CONDITION_ID, ConditionalModels.CONDITION_ID,
                                                       null);

            //then it is possible to trigger the conditional event
            testHelper.SetVariable(processInstance.Id, VAR_NAME, "1");

            testHelper.CompleteTask(ConditionalModels.USER_TASK_ID);
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #10
0
        public virtual void testMigrateParallelMultiInstanceTask()
        {
            // 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
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // 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)
                          .Activity("userTask", userTaskInstances[2].Id)
                          .Done());

            var migratedTasks = testHelper.SnapshotAfterMigration.Tasks;

            Assert.AreEqual(3, 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);
        }
Exemple #11
0
        public virtual void testCallBpmnProcessSimpleMigration()
        {
            // given
            var model = CallActivityModels.oneBpmnCallActivityProcess("oneTaskProcess");

            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 process instance
            testHelper.CompleteTask("userTask");
            // and the calling process instance
            testHelper.CompleteTask("userTask");

            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testTrees()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);

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

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

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

            // then the execution and activity instance tree are exactly as before migration
            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Child("externalTask")
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("externalTask"))
                     .Done());

            testHelper.AssertActivityTreeAfterMigration()
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(targetProcessDefinition.Id)
                          .Activity("externalTask", testHelper.GetSingleActivityInstanceBeforeMigration("externalTask")
                                    .Id)
                          .Done());
        }
Exemple #13
0
        public virtual void testMigrateJob()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);

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

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

            testHelper.AssertJobMigrated(testHelper.SnapshotBeforeMigration.Jobs[0], "timerCatch");

            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Child("timerCatch")
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("timerCatch"))
                     .Done());

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

            // and it is possible to trigger the event
            var jobAfterMigration = testHelper.SnapshotAfterMigration.Jobs[0];

            rule.ManagementService.ExecuteJob(jobAfterMigration.Id);

            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #14
0
        public virtual void testLogCreation()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                  .ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapEqualActivities()
                .Build();

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

            // when
            rule.IdentityService.AuthenticatedUserId = USER_ID;
            rule.RuntimeService.NewMigration(migrationPlan)
            .ProcessInstanceIds(processInstance.Id)
            .Execute();
            rule.IdentityService.ClearAuthentication();

            // then
            var opLogEntries = rule.HistoryService.CreateUserOperationLogQuery()

                               .ToList();

            Assert.AreEqual(3, opLogEntries.Count);

            var entries = asMap(opLogEntries);

            var procDefEntry = entries["processDefinitionId"];

            Assert.NotNull(procDefEntry);
            Assert.AreEqual("IProcessInstance", procDefEntry.EntityType);
            Assert.AreEqual("Migrate", procDefEntry.OperationType);
            Assert.AreEqual(sourceProcessDefinition.Id, procDefEntry.ProcessDefinitionId);
            Assert.AreEqual(sourceProcessDefinition.Key, procDefEntry.ProcessDefinitionKey);
            Assert.IsNull(procDefEntry.ProcessInstanceId);
            Assert.AreEqual(sourceProcessDefinition.Id, procDefEntry.OrgValue);
            Assert.AreEqual(targetProcessDefinition.Id, procDefEntry.NewValue);

            var asyncEntry = entries["async"];

            Assert.NotNull(asyncEntry);
            Assert.AreEqual("IProcessInstance", asyncEntry.EntityType);
            Assert.AreEqual("Migrate", asyncEntry.OperationType);
            Assert.AreEqual(sourceProcessDefinition.Id, asyncEntry.ProcessDefinitionId);
            Assert.AreEqual(sourceProcessDefinition.Key, asyncEntry.ProcessDefinitionKey);
            Assert.IsNull(asyncEntry.ProcessInstanceId);
            Assert.IsNull(asyncEntry.OrgValue);
            Assert.AreEqual("false", asyncEntry.NewValue);

            var numInstanceEntry = entries["nrOfInstances"];

            Assert.NotNull(numInstanceEntry);
            Assert.AreEqual("IProcessInstance", numInstanceEntry.EntityType);
            Assert.AreEqual("Migrate", numInstanceEntry.OperationType);
            Assert.AreEqual(sourceProcessDefinition.Id, numInstanceEntry.ProcessDefinitionId);
            Assert.AreEqual(sourceProcessDefinition.Key, numInstanceEntry.ProcessDefinitionKey);
            Assert.IsNull(numInstanceEntry.ProcessInstanceId);
            Assert.IsNull(numInstanceEntry.OrgValue);
            Assert.AreEqual("1", numInstanceEntry.NewValue);

            Assert.AreEqual(procDefEntry.OperationId, asyncEntry.OperationId);
            Assert.AreEqual(asyncEntry.OperationId, numInstanceEntry.OperationId);
        }
        public virtual void testMigrateWithIdVarargsArray()
        {
            var sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);

            var migrationPlan = runtimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id)
                                .MapEqualActivities()
                                .Build();

            var processInstance1 = runtimeService.StartProcessInstanceById(sourceDefinition.Id);
            var processInstance2 = runtimeService.StartProcessInstanceById(sourceDefinition.Id);

            // when
            runtimeService.NewMigration(migrationPlan)
            .ProcessInstanceIds(processInstance1.Id, processInstance2.Id)
            .Execute();

            // then
            Assert.AreEqual(2, runtimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == targetDefinition.Id)
                            .Count());
        }
Exemple #16
0
        public virtual void testRemoveMessageBoundaryEventFromUserTask()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                  //.ActivityBuilder("userTask")
                                                  //.BoundaryEvent("boundary")
                                                  ////.Message(MESSAGE_NAME)
                                                  //.UserTask(AFTER_BOUNDARY_TASK)
                                                  //.EndEvent()
                                                  //.Done()
                                                  );
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);

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

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.AssertEventSubscriptionRemoved("boundary", MESSAGE_NAME);

            // and it is possible to successfully complete the migrated instance
            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Exemple #17
0
        public virtual void testIntermediateConditionalEventWithSetVariableOnEndListener()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess()
                                                                            .StartEvent()
                                                                            .SubProcess()
                                                                            .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd,
                                                                                                           typeof(SetVariableDelegate).FullName)
                                                                            //.EmbeddedSubProcess()
                                                                            //.StartEvent()
                                                                            .IntermediateCatchEvent(ConditionalModels.CONDITION_ID)
                                                                            .ConditionalEventDefinition()
                                                                            //.Condition(ConditionalModels.VAR_CONDITION)
                                                                            //.ConditionalEventDefinitionDone()
                                                                            //.UserTask(AbstractConditionalEventTestCase.TaskAfterConditionId)
                                                                            //.EndEvent()
                                                                            .SubProcessDone()
                                                                            .EndEvent()
                                                                            .Done());
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent(ConditionalModels.CONDITION_ID)
                                                                            .ConditionalEventDefinition()
                                                                            //.Condition(ConditionalModels.VAR_CONDITION)
                                                                            //.ConditionalEventDefinitionDone()
                                                                            //.UserTask(AbstractConditionalEventTestCase.TaskAfterConditionId)
                                                                            //.EndEvent()
                                                                            .Done());

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(ConditionalModels.CONDITION_ID, ConditionalModels.CONDITION_ID)
                .UpdateEventTrigger()
                .Build();

            //when sub process is removed, end listener is called and sets variable
            var processInstance = testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            testHelper.AssertEventSubscriptionMigrated(ConditionalModels.CONDITION_ID, ConditionalModels.CONDITION_ID,
                                                       null);
            Assert.AreEqual(1, rule.RuntimeService.GetVariable(processInstance.Id, ConditionalModels.VARIABLE_NAME));

            //then conditional event is not triggered
            Assert.IsNull(rule.TaskService.CreateTaskQuery()
                          .First());

            //when any var is set
            testHelper.AnyVariable = processInstance.Id;

            //then condition is satisfied, since variable is already set which satisfies condition
            testHelper.CompleteTask(AbstractConditionalEventTestCase.TaskAfterConditionId);
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #18
0
        public virtual void testContinueProcess()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(TransactionModels.ONE_TASK_TRANSACTION);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(TransactionModels.ONE_TASK_TRANSACTION);

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

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

            // then
            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testParallelGatewayContinueExecution()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(GatewayModels.PARALLEL_GW);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(GatewayModels.PARALLEL_GW);

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

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

            testHelper.CompleteTask("parallel2");

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

            // then
            Assert.AreEqual(1, rule.TaskService.CreateTaskQuery()
                            .Count());
            Assert.AreEqual(0, rule.TaskService.CreateTaskQuery(c => c.TaskDefinitionKeyWithoutCascade == "afterJoin")
                            .Count());

            testHelper.CompleteTask("parallel1");
            testHelper.CompleteTask("afterJoin");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Exemple #20
0
        public virtual void testMigrateBoundaryEventOnUserTask()
        {
            // given
            var sourceProcess = ProcessModels.OneTaskProcess.Clone();
            var eventTrigger  = eventFactory.AddBoundaryEvent(rule.ProcessEngine, sourceProcess,
                                                              USER_TASK_ID, BOUNDARY_ID);

            ModifiableBpmnModelInstance.Wrap(sourceProcess)
            //.FlowNodeBuilder(BOUNDARY_ID)
            //.UserTask(AFTER_BOUNDARY_TASK)
            //.EndEvent()
            //.Done()
            ;

            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(sourceProcess)
                                               .ChangeElementId(BOUNDARY_ID, NEW_BOUNDARY_ID);

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(USER_TASK_ID, USER_TASK_ID)
                .MapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID)
                .UpdateEventTrigger()
                .Build();

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            eventTrigger.AssertEventTriggerMigrated(testHelper, NEW_BOUNDARY_ID);

            // and it is possible to successfully complete the migrated instance
            testHelper.CompleteTask(USER_TASK_ID);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
        public virtual void testRemoveScopeForNonScopeActivity()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.SubprocessProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);

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

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree("userTask")
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Done());

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

            var migratedTask = testHelper.SnapshotAfterMigration.GetTaskForKey("userTask");

            Assert.NotNull(migratedTask);
            Assert.AreEqual(targetProcessDefinition.Id, migratedTask.ProcessDefinitionId);

            // and it is possible to successfully complete the migrated instance
            rule.TaskService.Complete(migratedTask.Id);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
        public virtual void testMigrateActiveEventSubProcess()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);

            var processInstance = rule.RuntimeService.CreateProcessInstanceById(sourceProcessDefinition.Id)
                                  .StartBeforeActivity(EVENT_SUB_PROCESS_TASK_ID)
                                  .Execute();

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

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

            // then
            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(processInstance.Id)
                     .Child(EVENT_SUB_PROCESS_TASK_ID)
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("eventSubProcess"))
                     .Done());

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

            testHelper.AssertEventSubscriptionRemoved(EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.MESSAGE_NAME);
            testHelper.AssertEventSubscriptionCreated(EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.MESSAGE_NAME);

            // and it is possible to complete the process instance
            testHelper.CompleteTask(EVENT_SUB_PROCESS_TASK_ID);
            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testMigrateMultipleBoundaryEvents()
        {
            // given
            IBpmnModelInstance testProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.SubprocessProcess)
                                             //.ActivityBuilder("subProcess")
                                             //.BoundaryEvent("timerBoundary1")
                                             //.TimerWithDate(TIMER_DATE)
                                             //.MoveToActivity("subProcess")
                                             //.BoundaryEvent("messageBoundary1")
                                             ////.Message(MESSAGE_NAME)
                                             //.MoveToActivity("subProcess")
                                             //.BoundaryEvent("signalBoundary1")
                                             //.Signal(SIGNAL_NAME)
                                             //.MoveToActivity("subProcess")
                                             //.BoundaryEvent("conditionalBoundary1")
                                             //.Condition(VAR_CONDITION)
                                             //.MoveToActivity(USER_TASK_ID)
                                             //.BoundaryEvent("timerBoundary2")
                                             //.TimerWithDate(TIMER_DATE)
                                             //.MoveToActivity(USER_TASK_ID)
                                             //.BoundaryEvent("messageBoundary2")
                                             ////.Message(MESSAGE_NAME)
                                             //.MoveToActivity(USER_TASK_ID)
                                             //.BoundaryEvent("signalBoundary2")
                                             //.Signal(SIGNAL_NAME)
                                             //.MoveToActivity(USER_TASK_ID)
                                             //.BoundaryEvent("conditionalBoundary2")
                                             //.Condition(VAR_CONDITION)
                                             //.Done()
            ;

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

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("subProcess", "subProcess")
                .MapActivities("timerBoundary1", "timerBoundary1")
                .MapActivities("signalBoundary1", "signalBoundary1")
                .MapActivities("conditionalBoundary1", "conditionalBoundary1")
                .UpdateEventTrigger()
                .MapActivities(USER_TASK_ID, USER_TASK_ID)
                .MapActivities("messageBoundary2", "messageBoundary2")
                .Build();

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.AssertEventSubscriptionRemoved("messageBoundary1", MESSAGE_NAME);
            testHelper.AssertEventSubscriptionRemoved("signalBoundary2", SIGNAL_NAME);
            testHelper.AssertEventSubscriptionRemoved("conditionalBoundary2", null);
            testHelper.AssertEventSubscriptionMigrated("signalBoundary1", "signalBoundary1", SIGNAL_NAME);
            testHelper.AssertEventSubscriptionMigrated("messageBoundary2", "messageBoundary2", MESSAGE_NAME);
            testHelper.AssertEventSubscriptionMigrated("conditionalBoundary1", "conditionalBoundary1", null);
            testHelper.AssertEventSubscriptionCreated("messageBoundary1", MESSAGE_NAME);
            testHelper.AssertEventSubscriptionCreated("signalBoundary2", SIGNAL_NAME);
            testHelper.AssertEventSubscriptionCreated("conditionalBoundary2", null);
            testHelper.AssertBoundaryTimerJobRemoved("timerBoundary2");
            testHelper.AssertBoundaryTimerJobMigrated("timerBoundary1", "timerBoundary1");
            testHelper.AssertBoundaryTimerJobCreated("timerBoundary2");

            // and it is possible to successfully complete the migrated instance
            testHelper.CompleteTask(USER_TASK_ID);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
        public virtual void testMigrateGatewayExecutionTree()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);

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

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Child("eventBasedGateway")
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("eventBasedGateway"))
                     .Done());

            testHelper.AssertActivityTreeAfterMigration()
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(targetProcessDefinition.Id)
                          .Activity("eventBasedGateway",
                                    testHelper.GetSingleActivityInstanceBeforeMigration("eventBasedGateway")
                                    .Id)
                          .Done());
        }
Exemple #25
0
        public virtual void testVariableAtScopeExecutionInScopeActivity()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ONE_BOUNDARY_TASK);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ONE_BOUNDARY_TASK);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapEqualActivities()
                .Build();

            var processInstance = runtimeService.StartProcessInstanceById(sourceProcessDefinition.Id);
            var executionTreeBeforeMigration = ExecutionTree.ForExecution(processInstance.Id, rule.ProcessEngine);

            var scopeExecution = executionTreeBeforeMigration.Executions[0];

            runtimeService.SetVariableLocal(scopeExecution.Id, "foo", 42);

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

            // then
            var beforeMigration = testHelper.SnapshotBeforeMigration.GetSingleVariable("foo");

            Assert.AreEqual(1, testHelper.SnapshotAfterMigration.GetVariables()
                            .Count);
            testHelper.AssertVariableMigratedToExecution(beforeMigration, beforeMigration.ExecutionId);
        }
Exemple #26
0
        public virtual void testMigrateEventSubscription()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS);

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

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

            // then
            testHelper.AssertEventSubscriptionMigrated("signalCatch", "signalCatch", SignalCatchModels.SIGNAL_NAME);

            testHelper.AssertExecutionTreeAfterMigration()
            .HasProcessDefinitionId(targetProcessDefinition.Id)
            .Matches(ExecutionAssert.DescribeExecutionTree(null)
                     .Scope()
                     .Id(testHelper.SnapshotBeforeMigration.ProcessInstanceId)
                     .Child("signalCatch")
                     .Scope()
                     .Id(testHelper.GetSingleExecutionIdForActivityBeforeMigration("signalCatch"))
                     .Done());

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

            // and it is possible to trigger the event
            rule.RuntimeService.SignalEventReceived(SignalCatchModels.SIGNAL_NAME);

            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }