public virtual void testCase1()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);

            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 testMigrateEventSubprocessMessageKeepTrigger()
        {
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);

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

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

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

            // then
            testHelper.AssertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID,
                                                       EventSubProcessModels.MESSAGE_NAME);

            // and it is possible to trigger the event subprocess
            rule.RuntimeService.CorrelateMessage(EventSubProcessModels.MESSAGE_NAME);
            Assert.AreEqual(1, rule.TaskService.CreateTaskQuery()
                            .Count());

            // and complete the process instance
            testHelper.CompleteTask(EVENT_SUB_PROCESS_TASK_ID);
            testHelper.AssertProcessEnded(processInstance.Id);
        }
        public virtual void testMigrateGatewayWithMessageEventMapEvent()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);

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

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

            // then
            testHelper.AssertEventSubscriptionMigrated("messageCatch", "messageCatch",
                                                       EventBasedGatewayModels.MESSAGE_NAME);

            rule.RuntimeService.CorrelateMessage(EventBasedGatewayModels.MESSAGE_NAME);

            testHelper.CompleteTask("afterMessageCatch");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Beispiel #4
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 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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
        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);
        }