public virtual void testCanOnlyTriggerCompensationInParentOfRemovedScope()
        {
            var sourceModel = ProcessModels.NewModel()
                              .StartEvent()
                              .SubProcess("outerSubProcess")
                              //.EmbeddedSubProcess()
                              //.StartEvent()
                              .UserTask("userTask1")
                              .BoundaryEvent("compensationBoundary")
                              //.CompensateEventDefinition()
                              //.CompensateEventDefinitionDone()
                              //.MoveToActivity("userTask1")
                              .SubProcess("innerSubProcess")
                              //.EmbeddedSubProcess()
                              //.StartEvent()
                              .UserTask("userTask2")
                              .EndEvent()
                              .SubProcessDone()
                              .EndEvent()
                              .SubProcessDone()
                              .Done();

            CompensationModels.addUserTaskCompensationHandler(sourceModel, "compensationBoundary", "compensationHandler");

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceModel);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(
                    ModifiableBpmnModelInstance.Modify(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL)
                    .EndEventBuilder("subProcessEnd")
                    //.CompensateEventDefinition()
                    //.WaitForCompletion(true)
                    //.CompensateEventDefinitionDone()
                    .Done());

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

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

            testHelper.CompleteTask("userTask1");
            testHelper.MigrateProcessInstance(migrationPlan, processInstance);

            // when
            testHelper.CompleteTask("userTask2");

            // then compensation is not triggered from inside the inner sub process
            // but only on process definition level
            var activityInstance = rule.RuntimeService.GetActivityInstance(processInstance.Id);

            ActivityInstanceAssert.That(activityInstance)
            .HasStructure(ActivityInstanceAssert.DescribeActivityInstanceTree(targetProcessDefinition.Id)
                          .Activity("compensationEvent")
                          .BeginScope("subProcess")
                          .Activity("compensationHandler")
                          .Done());
        }
Ejemplo n.º 2
0
        public virtual void testChangeTaskType()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .BusinessRuleTask("externalBusinessRuleTask")
                                                                            .CamundaType(ExternalTaskModels.EXTERNAL_TASK_TYPE)
                                                                            .CamundaTopic(ExternalTaskModels.TOPIC)
                                                                            .CamundaTaskPriority(ExternalTaskModels.PRIORITY.ToString())
                                                                            .EndEvent()
                                                                            .Done());

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

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

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

            // then the task and process can be completed
            var task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);

            rule.ExternalTaskService.Complete(task.Id, WORKER_ID);

            testHelper.AssertProcessEnded(processInstance.Id);
        }
Ejemplo n.º 3
0
        public virtual void testMigrateEventSubscriptionPreserveMessageName()
        {
            // given
            var sourceProcessDefinition =
                testHelper.DeployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent("messageCatch")
                                                                            .Message("new" + MessageReceiveModels.MESSAGE_NAME)
                                                                            .UserTask("userTask")
                                                                            .EndEvent()
                                                                            .Done());

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

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

            // then the message event subscription's event name has not changed
            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);
        }
Ejemplo n.º 4
0
        public virtual void testMigrateJobPreserveTimerConfiguration()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent("timerCatch")
                                                                            .TimerWithDuration("PT50M")
                                                                            .UserTask("userTask")
                                                                            .EndEvent()
                                                                            .Done());

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

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

            // then
            testHelper.AssertJobMigrated(testHelper.SnapshotBeforeMigration.Jobs[0], "timerCatch");
            // this also Asserts that the due has not changed

            // 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);
        }
        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");
            }
        }
Ejemplo n.º 6
0
        public virtual void testMigrateEventSubscriptionUpdateSignalName()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent("signalCatch")
                                                                            .Signal("new" + SignalCatchModels.SIGNAL_NAME)
                                                                            .UserTask("userTask")
                                                                            .EndEvent()
                                                                            .Done());

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

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

            // then the message event subscription's event name has not changed
            testHelper.AssertEventSubscriptionMigrated("signalCatch", SignalCatchModels.SIGNAL_NAME, "signalCatch",
                                                       "new" + SignalCatchModels.SIGNAL_NAME);

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

            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Ejemplo n.º 7
0
        public virtual void testInvokeListenersWhenDeletingProcessInstancesAsync()
        {
            // given
            IncrementCounterListener.Counter = 0;

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            var instance = ProcessModels.NewModel(OneTaskProcess)
                           .StartEvent()
                           .UserTask()
                           .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd,
                                                          typeof(IncrementCounterListener).FullName)
                           .EndEvent()
                           .Done();

            migrationRule.Deploy(instance);
            var processIds = startTestProcesses(1);

            // when
            var batch = runtimeService.DeleteProcessInstancesAsync(processIds, TESTING_INSTANCE_DELETE);

            executeSeedJob(batch);
            executeBatchJobs(batch);

            // then
            Assert.That(IncrementCounterListener.Counter, Is.EqualTo(1));
        }
 public virtual IBpmnModelInstance Build()
 {
     return(ProcessModels.NewModel(ProcessKeyRenamed)
            .StartEvent()
            .ServiceTask(ExternalTaskNameRenamed)
            .CamundaType(ExternalTaskTypeRenamed)
            .CamundaTopic(TopicRenamed)
            .CamundaTaskPriority(PriorityRenamed.ToString())
            .EndEvent()
            .Done());
 }
Ejemplo n.º 9
0
        public virtual void testMigrateEventSubscriptionUpdateSignalExpressionNameWithVariables()
        {
            // given
            var newSignalName           = "new" + SignalCatchModels.SIGNAL_NAME + "-${var}";
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent("signalCatch")
                                                                            .Signal(newSignalName)
                                                                            .UserTask("userTask")
                                                                            .EndEvent()
                                                                            .Done());

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

            var variables = new Dictionary <string, object>();

            variables["var"] = "foo";


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

            // then there should be a variable
            var beforeMigration = testHelper.SnapshotBeforeMigration.GetSingleVariable("var");

            Assert.AreEqual(1, testHelper.SnapshotAfterMigration.GetVariables()
                            .Count);
            testHelper.AssertVariableMigratedToExecution(beforeMigration, beforeMigration.ExecutionId);

            // and the signal event subscription's event name has changed
            var resolvedSignalName = "new" + SignalCatchModels.SIGNAL_NAME + "-foo";

            testHelper.AssertEventSubscriptionMigrated("signalCatch", SignalCatchModels.SIGNAL_NAME, "signalCatch",
                                                       resolvedSignalName);

            // and it is possible to trigger the event and complete the task afterwards
            rule.RuntimeService.SignalEventReceived(resolvedSignalName);

            testHelper.CompleteTask("userTask");
            testHelper.AssertProcessEnded(processInstance.Id);
        }
Ejemplo n.º 10
0
        public virtual void testMigrateJobUpdateTimerConfiguration()
        {
            // given
            ClockTestUtil.SetClockToDateWithoutMilliseconds();

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.NewModel()
                                                                            .StartEvent()
                                                                            .IntermediateCatchEvent("timerCatch")
                                                                            .TimerWithDuration("PT50M")
                                                                            .UserTask("userTask")
                                                                            .EndEvent()
                                                                            .Done());

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

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

            // then
            var newDueDate = new DateTime(ClockUtil.CurrentTime.Ticks).AddMinutes(50);

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

            // 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);
        }