Ejemplo n.º 1
0
        public virtual void testUpdateEventTrigger()
        {
            // given
            var newMessageName = "newMessage";

            var sourceProcessDefinition = migrationRule.DeployAndGetDefinition(ProcessModels.OneReceiveTaskProcess);
            var targetProcessDefinition =
                migrationRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(
                                                         ProcessModels.OneReceiveTaskProcess)
                                                     .RenameMessage("Message", newMessageName));

            var processInstance = runtimeService.StartProcessInstanceById(sourceProcessDefinition.Id);
            var migrationPlan   =
                runtimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapEqualActivities()
                .UpdateEventTriggers()
                .Build();

            var batch = runtimeService.NewMigration(migrationPlan)
                        .ProcessInstanceIds(new List <string> {
                processInstance.Id
            })
                        .ExecuteAsync();

            helper.ExecuteSeedJob(batch);

            // when
            helper.ExecuteJobs(batch);

            // then the message event subscription's event name was changed
            var eventSubscription = runtimeService.CreateEventSubscriptionQuery()
                                    .First();

            Assert.AreEqual(newMessageName, eventSubscription.EventName);
        }
Ejemplo n.º 2
0
        public virtual void testSkipIoMappingInvocationForNewlyCreatedScope()
        {
            // given
            var sourceProcessDefinition = migrationRule.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                migrationRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.SubprocessProcess)
                                                     //.ActivityBuilder("subProcess")
                                                     //.camundaInputParameter("foo", "bar")
                                                     //.Done()
                                                     );

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

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

            var batch = engineRule.RuntimeService.NewMigration(migrationPlan)
                        .ProcessInstanceIds(processInstance.Id)
                        .SkipIoMappings()
                        .ExecuteAsync();

            helper.ExecuteSeedJob(batch);

            // when
            helper.ExecuteJobs(batch);

            // then
            Assert.AreEqual(0, engineRule.RuntimeService.CreateVariableInstanceQuery()
                            .Count());
        }
Ejemplo n.º 3
0
        public virtual void testSkipListenerInvocationForNewlyCreatedScope()
        {
            // given
            DelegateEvent.ClearEvents();

            var sourceProcessDefinition = migrationRule.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            var targetProcessDefinition =
                migrationRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.SubprocessProcess)
                                                     //.ActivityBuilder("subProcess")
                                                     //.CamundaExecutionListenerClass(ExecutionListenerFields.EventNameStart,
                                                     //    typeof(DelegateExecutionListener).FullName)
                                                     /*.Done()*/);

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

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

            var batch = engineRule.RuntimeService.NewMigration(migrationPlan)
                        .ProcessInstanceIds(processInstance.Id)
                        .SkipCustomListeners()
                        .ExecuteAsync();

            helper.ExecuteSeedJob(batch);

            // when
            helper.ExecuteJobs(batch);

            // then
            Assert.AreEqual(0, DelegateEvent.Events.Count);
        }
Ejemplo n.º 4
0
        public virtual void testMigrateHistoricIncident()
        {
            // given
            var sourceProcess = testHelper.DeployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
            var targetProcess =
                testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(
                                                      AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS)
                                                  .ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey)
                                                  .ChangeElementId("userTask", "newUserTask"));

            var targetJobDefinition = managementService.CreateJobDefinitionQuery(c => c.ProcessDefinitionId == targetProcess.Id)
                                      .First();

            var migrationPlan = runtimeService.CreateMigrationPlan(sourceProcess.Id, targetProcess.Id)
                                .MapActivities("userTask", "newUserTask")
                                .Build();

            var processInstance = runtimeService.StartProcessInstanceById(sourceProcess.Id);

            var job = managementService.CreateJobQuery()
                      .First();

            managementService.SetJobRetries(job.Id, 0);

            var incidentBeforeMigration = historyService.CreateHistoricIncidentQuery()
                                          .First();

            // when
            runtimeService.NewMigration(migrationPlan)
            .ProcessInstanceIds(processInstance.Id)
            .Execute();

            // then
            var historicIncident = historyService.CreateHistoricIncidentQuery()
                                   .First();

            Assert.NotNull(historicIncident);

            Assert.AreEqual("newUserTask", historicIncident.ActivityId);
            Assert.AreEqual(targetJobDefinition.Id, historicIncident.JobDefinitionId);
            Assert.AreEqual(targetProcess.Id, historicIncident.ProcessDefinitionId);
            Assert.AreEqual(targetProcess.Key, historicIncident.ProcessDefinitionKey);
            Assert.AreEqual(processInstance.Id, historicIncident.ExecutionId);

            // and other properties have not changed
            Assert.AreEqual(incidentBeforeMigration.CreateTime, historicIncident.CreateTime);
            Assert.AreEqual(incidentBeforeMigration.ProcessInstanceId, historicIncident.ProcessInstanceId);
        }
        public virtual void initTest()
        {
            runtimeService = rule.RuntimeService;
            historyService = rule.HistoryService;


            sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var modifiedModel = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                .ChangeElementId("Process", "Process2")
                                .ChangeElementId("userTask", "userTask2");

            targetProcessDefinition = testHelper.DeployAndGetDefinition(modifiedModel);
            migrationPlan           = runtimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                                      .MapActivities("userTask", "userTask2")
                                      .Build();
            runtimeService.StartProcessInstanceById(sourceProcessDefinition.Id);
        }
        public virtual void testCreate()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).Start();

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.NotNull(migrationPlan);
            }
        }
        public virtual void testMigrateHistoryUserTaskInstance()
        {
            //given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                  .ChangeElementId("Process", "Process2")
                                                  .ChangeElementId("userTask", "userTask2"));

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

            var processInstance = runtimeService.StartProcessInstanceById(sourceProcessDefinition.Id);

            var sourceHistoryTaskInstanceQuery = historyService.CreateHistoricTaskInstanceQuery(c => c.ProcessDefinitionId == sourceProcessDefinition.Id);
            var targetHistoryTaskInstanceQuery = historyService.CreateHistoricTaskInstanceQuery(c => c.ProcessDefinitionId == targetProcessDefinition.Id);

            var activityInstance = runtimeService.GetActivityInstance(processInstance.Id);

            //when
            Assert.AreEqual(1, sourceHistoryTaskInstanceQuery.Count());
            Assert.AreEqual(0, targetHistoryTaskInstanceQuery.Count());
            var sourceProcessInstanceQuery = runtimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == sourceProcessDefinition.Id);

            runtimeService.NewMigration(migrationPlan)
            .ProcessInstanceQuery(sourceProcessInstanceQuery)
            .Execute();

            //then
            Assert.AreEqual(0, sourceHistoryTaskInstanceQuery.Count());
            Assert.AreEqual(1, targetHistoryTaskInstanceQuery.Count());

            var instance = targetHistoryTaskInstanceQuery.First();

            Assert.AreEqual(targetProcessDefinition.Key, instance.ProcessDefinitionKey);
            Assert.AreEqual(targetProcessDefinition.Id, instance.ProcessDefinitionId);
            Assert.AreEqual("userTask2", instance.TaskDefinitionKey);
            Assert.AreEqual(activityInstance.GetActivityInstances("userTask")[0].Id, instance.ActivityInstanceId);
        }
Ejemplo n.º 8
0
        public virtual void testMigrateHistoryActivityInstance()
        {
            //given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                  .ChangeElementId("Process", "Process2")
                                                  .ChangeElementId("userTask", "userTask2")
                                                  .ChangeElementName("userTask", "new activity name"));

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

            var processInstance = runtimeService.StartProcessInstanceById(sourceProcessDefinition.Id);

            var sourceHistoryActivityInstanceQuery = historyService.CreateHistoricActivityInstanceQuery(c => c.ProcessDefinitionId == sourceProcessDefinition.Id);
            var targetHistoryActivityInstanceQuery = historyService.CreateHistoricActivityInstanceQuery(c => c.ProcessDefinitionId == targetProcessDefinition.Id);

            //when
            Assert.AreEqual(2, sourceHistoryActivityInstanceQuery.Count());
            Assert.AreEqual(0, targetHistoryActivityInstanceQuery.Count());
            var sourceProcessInstanceQuery = runtimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == sourceProcessDefinition.Id);

            runtimeService.NewMigration(migrationPlan)
            .ProcessInstanceQuery(sourceProcessInstanceQuery)
            .Execute();

            // then one instance of the start event still belongs to the source process
            // and one active user task instances is now migrated to the target process
            Assert.AreEqual(1, sourceHistoryActivityInstanceQuery.Count());
            Assert.AreEqual(1, targetHistoryActivityInstanceQuery.Count());

            var instance = targetHistoryActivityInstanceQuery.First();

            AssertMigratedTo(instance, targetProcessDefinition, "userTask2");
            Assert.AreEqual("new activity name", instance.ActivityName);
            Assert.AreEqual(processInstance.Id, instance.ParentActivityInstanceId);
            Assert.AreEqual("userTask", instance.ActivityType);
        }
        public virtual void testMigrate()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).BindResource("processInstance", processInstance.Id).Start();

            batch = engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceIds((processInstance.Id)).ExecuteAsync();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(1, engineRule.ManagementService.CreateBatchQuery().Count());
            }
        }
Ejemplo n.º 10
0
        public virtual void testEndExecutionListenerIsCalledOnlyOnce()
        {
            //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("conditionalProcessKey")
                                               .StartEvent()
                                               .UserTask()
                                               .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd, typeof(SetVariableDelegate).FullName)
                                               .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd,
                                                                              typeof(RecorderExecutionListener).FullName)
                                               .EndEvent()
                                               .Done();

            modelInstance = ModifiableBpmnModelInstance.Modify(modelInstance)
                            .AddSubProcessTo("conditionalProcessKey")
                            .TriggerByEvent()
                            //.EmbeddedSubProcess()
                            //.StartEvent()
                            //.Interrupting(true)
                            //.ConditionalEventDefinition()
                            //.Condition("${variable == 1}")
                            //.ConditionalEventDefinitionDone()
                            .EndEvent()
                            .Done();

            testHelper.Deploy(modelInstance);

            // given
            var procInst = runtimeService.StartProcessInstanceByKey("conditionalProcessKey");
            IQueryable <ITask> taskQuery = taskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id);

            //when task is completed
            taskService.Complete(taskQuery.First()
                                 .Id);

            //then end listener sets variable and triggers conditional event
            //end listener should called only once
            Assert.AreEqual(1, RecorderExecutionListener.RecordedEvents.Count);
        }
        public virtual void testListenerInvocation()
        {
            // given
            DelegateEvent.ClearEvents();
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            var processDefinition = testRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(instance)
                                                                    //.ActivityBuilder("user2")
                                                                    //.CamundaExecutionListenerClass(ExecutionListenerFields.EventNameStart,
                                                                    //    typeof(DelegateExecutionListener).FullName)
                                                                    //.Done()
                                                                    );

            var processInstance = runtimeService.StartProcessInstanceById(processDefinition.Id);

            var batch = runtimeService.CreateModification(processDefinition.Id)
                        .StartBeforeActivity("user2")
                        .SetProcessInstanceIds(processInstance.Id)
                        .ExecuteAsync();

            helper.ExecuteSeedJob(batch);

            // when
            helper.ExecuteJobs(batch);

            // then
            var recordedEvents = DelegateEvent.Events;

            Assert.AreEqual(1, recordedEvents.Count);

            var @event = recordedEvents[0];

            Assert.AreEqual(processDefinition.Id, @event.ProcessDefinitionId);
            Assert.AreEqual("user2", @event.CurrentActivityId);

            DelegateEvent.ClearEvents();
        }
Ejemplo n.º 12
0
        public virtual void testLogCreation()
        {
            // given
            var sourceProcessDefinition = migrationRule.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            var targetProcessDefinition =
                migrationRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                     .ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

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

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

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

            // then
            var opLogEntries = engineRule.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("true", asyncEntry.NewValue);

            var numInstancesEntry = entries["nrOfInstances"];

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

            Assert.AreEqual(procDefEntry.OperationId, asyncEntry.OperationId);
            Assert.AreEqual(asyncEntry.OperationId, numInstancesEntry.OperationId);
        }
Ejemplo n.º 13
0
        public virtual void testDeleteProcessInstancesAsyncWithListInDifferentDeployments()
        {
            // given
            var sourceDefinition1 =
                testRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                                .ChangeElementId(ProcessModels.ProcessKey, "OneTaskProcess"));
            var sourceDefinition2 =
                testRule.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.TwoTasksProcess)
                                                .ChangeElementId(ProcessModels.ProcessKey, "TWO_TASKS_PROCESS"));
            var processInstanceIds = createProcessInstances(sourceDefinition1, sourceDefinition2, 15, 10);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String firstDeploymentId = sourceDefinition1.GetDeploymentId();
            var firstDeploymentId = sourceDefinition1.DeploymentId;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String secondDeploymentId = sourceDefinition2.GetDeploymentId();
            var secondDeploymentId = sourceDefinition2.DeploymentId;

            var processInstanceIdsFromFirstDeployment  = getProcessInstanceIdsByDeploymentId(firstDeploymentId);
            var processInstanceIdsFromSecondDeployment = getProcessInstanceIdsByDeploymentId(secondDeploymentId);

            engineRule.ProcessEngineConfiguration.InvocationsPerBatchJob = 2;
            engineRule.ProcessEngineConfiguration.BatchJobsPerSeed       = 3;

            // when
            var batch = runtimeService.DeleteProcessInstancesAsync(processInstanceIds, null, "test_reason");

            var seedJobDefinitionId = batch.SeedJobDefinitionId;
            // seed jobs
            var expectedSeedJobsCount = 5;

            createAndExecuteSeedJobs(seedJobDefinitionId, expectedSeedJobsCount);

            // then
            var jobs = managementService.CreateJobQuery(c => c.JobDefinitionId == batch.BatchJobDefinitionId)

                       .ToList();

            // execute jobs related to the first deployment
            var jobIdsForFirstDeployment = getJobIdsByDeployment(jobs, firstDeploymentId);

            Assert.NotNull(jobIdsForFirstDeployment);
            foreach (var jobId in jobIdsForFirstDeployment)
            {
                managementService.ExecuteJob(jobId);
            }

            // the process instances related to the first deployment should be deleted
            Assert.AreEqual(0, runtimeService.CreateProcessInstanceQuery()
                            //.SetDeploymentId(firstDeploymentId)
                            .Count());
            AssertHistoricTaskDeletionPresent(processInstanceIdsFromFirstDeployment, "test_reason", testRule);
            // and process instances related to the second deployment should not be deleted
            Assert.AreEqual(processInstanceIdsFromSecondDeployment.Count, runtimeService.CreateProcessInstanceQuery()
                            //.SetDeploymentId(secondDeploymentId)
                            .Count());
            AssertHistoricTaskDeletionPresent(processInstanceIdsFromSecondDeployment, null, testRule);

            // execute jobs related to the second deployment
            var jobIdsForSecondDeployment = getJobIdsByDeployment(jobs, secondDeploymentId);

            Assert.NotNull(jobIdsForSecondDeployment);
            foreach (var jobId in jobIdsForSecondDeployment)
            {
                managementService.ExecuteJob(jobId);
            }

            // all of the process instances should be deleted
            Assert.AreEqual(0, runtimeService.CreateProcessInstanceQuery()
                            .Count());
        }
        public virtual void testBothInstanceAndLocalVariableMessageCorrelation()
        {
            //given
            var model = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("Process_1")
                        .StartEvent()
                        .SubProcess("SubProcess_1")
                        .EmbeddedSubProcess()
                        .StartEvent()
                        .ReceiveTask("MessageReceiver_1")
                        .Message(TEST_MESSAGE_NAME)
                        .UserTask("UserTask_1")
                        .EndEvent()
                        .SubProcessDone()
                        .MultiInstance()
                        .CamundaCollection("${vars}")
                        .CamundaElementVariable("loopVar")
                        .MultiInstanceDone()
                        .EndEvent()
                        .Done();

            model = ModifiableBpmnModelInstance.Modify(model)
                    .ActivityBuilder <AbstractActivityBuilder <IActivity>, IActivity>("MessageReceiver_1")
                    .CamundaInputParameter("localVar", "${loopVar}")
                    .CamundaInputParameter("constVar", "someValue")
                    .Done()
            ;     //to test array of parameters

            testHelper.Deploy(model);

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

            variables["vars"] = new[] { 1, 2, 3 };
            variables["processInstanceVar"] = "processInstanceVarValue";
            var processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("Process_1", variables);

            //second process instance with another process instance variable value
            variables         = new Dictionary <string, object>();
            variables["vars"] = new[] { 1, 2, 3 };
            variables["processInstanceVar"] = "anotherProcessInstanceVarValue";
            engineRule.RuntimeService.StartProcessInstanceByKey("Process_1", variables);

            //when correlated by local variables
            var messageName = TEST_MESSAGE_NAME;
            IDictionary <string, object> correlationKeys = new Dictionary <string, object>();
            var correlationKey = 1;

            correlationKeys["localVar"] = correlationKey;
            correlationKeys["constVar"] = "someValue";
            IDictionary <string, object> processInstanceKeys = new Dictionary <string, object>();
            var processInstanceVarValue = "processInstanceVarValue";

            processInstanceKeys["processInstanceVar"] = processInstanceVarValue;
            IDictionary <string, object> messagePayload = new Dictionary <string, object>();

            messagePayload["newVar"] = "newValue";

            var messageCorrelationResult =
                engineRule.RuntimeService.CreateMessageCorrelation(messageName)
                .ProcessInstanceVariablesEqual(processInstanceKeys)
                .LocalVariablesEqual(correlationKeys)
                .SetVariables(messagePayload)
                .CorrelateWithResult();

            //then exactly one message is correlated = one receive task is passed by, two + three others continue waiting
            checkExecutionMessageCorrelationResult(messageCorrelationResult, processInstance, "MessageReceiver_1");

            //uncorrelated executions
            var uncorrelatedExecutions = engineRule.RuntimeService.CreateExecutionQuery(c => c.ActivityId == "MessageReceiver_1")

                                         .ToList();

            Assert.AreEqual(5, uncorrelatedExecutions.Count);
        }