Exemple #1
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);
        }
Exemple #2
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);
        }