コード例 #1
0
        public virtual void noHistoryUpdateOnAddScopeMigration()
        {
            // given
            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);

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

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

            var userTask1CCExecutionBefore = executionTreeBeforeMigration.GetLeafExecutions("userTask1")[0].Parent;

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

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

            // then there is still one historic variable instance
            Assert.AreEqual(1, historyService.CreateHistoricVariableInstanceQuery()
                            .Count());

            // and no additional historic details
            Assert.AreEqual(1, historyService.CreateHistoricDetailQuery()
                            .Count());
        }
コード例 #2
0
 public virtual IBatch MigrateProcessInstancesAsync(int numberOfProcessInstances)
 {
     sourceProcessDefinition = MigrationRule.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
     targetProcessDefinition = MigrationRule.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
     return(MigrateProcessInstancesAsync(numberOfProcessInstances, sourceProcessDefinition,
                                         targetProcessDefinition));
 }
コード例 #3
0
        public virtual void testMigrateHistoricSubProcessInstance()
        {
            //given
            var processDefinition = testHelper.DeployAndGetDefinition(ProcessModels.ScopeTaskSubprocessProcess);

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

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

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

            // then
            var historicInstances = historyService.CreateHistoricActivityInstanceQuery(c => c.ProcessInstanceId == processInstance.Id)
                                    /*.Unfinished()*/
                                    /*.OrderByActivityId()*/
                                    /*.Asc()*/

                                    .ToList();

            Assert.AreEqual(2, historicInstances.Count);

            AssertMigratedTo(historicInstances[0], processDefinition, "subProcess");
            AssertMigratedTo(historicInstances[1], processDefinition, "userTask");
            Assert.AreEqual(processInstance.Id, historicInstances[0].ParentActivityInstanceId);
            Assert.AreEqual(historicInstances[0].Id, historicInstances[1].ParentActivityInstanceId);
        }
コード例 #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);
        }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }