Exemplo n.º 1
0
        public virtual void testMigrateHistoryUserTaskInstance()
        {
            //given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2"));

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            HistoricTaskInstanceQuery sourceHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);
            HistoricTaskInstanceQuery targetHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(targetProcessDefinition.Id);

            ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.Id);

            //when
            assertEquals(1, sourceHistoryTaskInstanceQuery.count());
            assertEquals(0, targetHistoryTaskInstanceQuery.count());
            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);

            runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();

            //then
            assertEquals(0, sourceHistoryTaskInstanceQuery.count());
            assertEquals(1, targetHistoryTaskInstanceQuery.count());

            HistoricTaskInstance instance = targetHistoryTaskInstanceQuery.singleResult();

            assertEquals(targetProcessDefinition.Key, instance.ProcessDefinitionKey);
            assertEquals(targetProcessDefinition.Id, instance.ProcessDefinitionId);
            assertEquals("userTask2", instance.TaskDefinitionKey);
            assertEquals(activityInstance.getActivityInstances("userTask")[0].Id, instance.ActivityInstanceId);
        }
Exemplo n.º 2
0
        public virtual void testMigrateHistoryActivityInstance()
        {
            //given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2").changeElementName("userTask", "new activity name"));

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            HistoricActivityInstanceQuery sourceHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);
            HistoricActivityInstanceQuery targetHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(targetProcessDefinition.Id);

            //when
            assertEquals(2, sourceHistoryActivityInstanceQuery.count());
            assertEquals(0, targetHistoryActivityInstanceQuery.count());
            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().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
            assertEquals(1, sourceHistoryActivityInstanceQuery.count());
            assertEquals(1, targetHistoryActivityInstanceQuery.count());

            HistoricActivityInstance instance = targetHistoryActivityInstanceQuery.singleResult();

            assertMigratedTo(instance, targetProcessDefinition, "userTask2");
            assertEquals("new activity name", instance.ActivityName);
            assertEquals(processInstance.Id, instance.ParentActivityInstanceId);
            assertEquals("userTask", instance.ActivityType);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        public virtual void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        {
            // given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.Id);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).executeAsync();
            Job seedJob = managementService.createJobQuery().singleResult();

            managementService.executeJob(seedJob.Id);

            Job migrationJob = managementService.createJobQuery().jobDefinitionId(batch.BatchJobDefinitionId).singleResult();

            // when
            managementService.executeJob(migrationJob.Id);

            // then
            assertEquals(9, userOperationLogQuery().count());
            assertEquals(2, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.DEPLOYMENT).count());
            assertEquals(1, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
            assertEquals(3, userOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MIGRATE).entityType(EntityTypes.PROCESS_INSTANCE).count());
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCustomIncidentMigrationWithoutConfiguration()
        public virtual void testCustomIncidentMigrationWithoutConfiguration()
        {
            // given
            RuntimeService    runtimeService = engineRule.RuntimeService;
            BpmnModelInstance instance1      = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
            BpmnModelInstance instance2      = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();

            testHelper.deploy(instance1, instance2);

            ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processInstance1.ProcessDefinitionId, processInstance2.ProcessDefinitionId).mapActivities("u1", "u2").build();

            runtimeService.createIncident("custom", processInstance1.Id, null);

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.Id).execute();

            // then
            Incident incident = runtimeService.createIncidentQuery().singleResult();

            assertEquals(processInstance2.ProcessDefinitionId, incident.ProcessDefinitionId);
            assertEquals("custom", incident.IncidentType);
            assertEquals(processInstance1.Id, incident.ExecutionId);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery()
        public virtual void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery()
        {
            RuntimeService runtimeService       = engineRule.RuntimeService;
            int            processInstanceCount = 15;

            ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            IList <string> processInstanceIds = new List <string>();

            for (int i = 0; i < processInstanceCount; i++)
            {
                processInstanceIds.Add(runtimeService.startProcessInstanceById(sourceProcessDefinition.Id).Id);
            }

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);

            assertEquals(processInstanceCount, sourceProcessInstanceQuery.count());

            // when
            Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceIds).processInstanceQuery(sourceProcessInstanceQuery).executeAsync();

            // then a batch is created
            assertBatchCreated(batch, processInstanceCount);
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateEventSubscription()
        public virtual void testMigrateEventSubscription()
        {
            // given
            ProcessDefinition sourceProcessDefinition   = testHelper.deployAndGetDefinition(MessageReceiveModels.MESSAGE_START_PROCESS);
            string            sourceProcessDefinitionId = sourceProcessDefinition.Id;

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinitionId, sourceProcessDefinitionId).mapEqualActivities().build();

            ProcessInstance   processInstance   = runtimeService.startProcessInstanceById(sourceProcessDefinitionId);
            EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().activityId("startEvent").eventName(MessageReceiveModels.MESSAGE_NAME).singleResult();

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute();

            // then
            assertEventSubscriptionMigrated(eventSubscription, "startEvent", MessageReceiveModels.MESSAGE_NAME);

            testHelper.completeTask("userTask");
            testHelper.assertProcessEnded(processInstance.Id);
        }
Exemplo n.º 7
0
        public virtual void migrateProcessInstance(MigrationPlan migrationPlan, ProcessInstance processInstance)
        {
            snapshotBeforeMigration = takeFullProcessInstanceSnapshot(processInstance);

            RuntimeService runtimeService = processEngine.RuntimeService;

            runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(snapshotBeforeMigration.ProcessInstanceId)).execute();

            // fetch updated process instance
            processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.Id).singleResult();

            snapshotAfterMigration = takeFullProcessInstanceSnapshot(processInstance);
        }
Exemplo n.º 8
0
        protected internal virtual Batch createFailingMigrationBatch()
        {
            BpmnModelInstance instance = createModelInstance();

            ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(instance);
            ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(instance);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id, "unknownId")).executeAsync();

            return(batch);
        }
Exemplo n.º 9
0
        public virtual Batch migrateProcessInstancesAsync(int numberOfProcessInstances, ProcessDefinition sourceProcessDefinition, ProcessDefinition targetProcessDefinition)
        {
            RuntimeService runtimeService = engineRule.RuntimeService;

            IList <string> processInstanceIds = new List <string>(numberOfProcessInstances);

            for (int i = 0; i < numberOfProcessInstances; i++)
            {
                processInstanceIds.Add(runtimeService.startProcessInstanceById(sourceProcessDefinition.Id).Id);
            }

            MigrationPlan migrationPlan = engineRule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build();

            return(runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceIds).executeAsync());
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateHistoricIncident()
        public virtual void testMigrateHistoricIncident()
        {
            // given
            ProcessDefinition sourceProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
            ProcessDefinition targetProcess = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY).changeElementId("userTask", "newUserTask"));

            JobDefinition targetJobDefinition = managementService.createJobDefinitionQuery().processDefinitionId(targetProcess.Id).singleResult();

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcess.Id, targetProcess.Id).mapActivities("userTask", "newUserTask").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcess.Id);

            Job job = managementService.createJobQuery().singleResult();

            managementService.setJobRetries(job.Id, 0);

            HistoricIncident incidentBeforeMigration = historyService.createHistoricIncidentQuery().singleResult();

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();

            // then
            HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();

            Assert.assertNotNull(historicIncident);

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

            // and other properties have not changed
            Assert.assertEquals(incidentBeforeMigration.CreateTime, historicIncident.CreateTime);
            Assert.assertEquals(incidentBeforeMigration.ProcessInstanceId, historicIncident.ProcessInstanceId);
        }
Exemplo n.º 11
0
        public virtual void testMigrateHistoryVariableInstance()
        {
            //given
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.Id);

            runtimeService.setVariable(processInstance.Id, "test", 3537);
            HistoricVariableInstance instance = historyService.createHistoricVariableInstanceQuery().singleResult();

            MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapActivities("userTask", "userTask").build();

            //when
            runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();

            //then
            HistoricVariableInstance migratedInstance = historyService.createHistoricVariableInstanceQuery().singleResult();

            assertEquals(targetDefinition.Key, migratedInstance.ProcessDefinitionKey);
            assertEquals(targetDefinition.Id, migratedInstance.ProcessDefinitionId);
            assertEquals(instance.ActivityInstanceId, migratedInstance.ActivityInstanceId);
            assertEquals(instance.ExecutionId, migratedInstance.ExecutionId);
        }
Exemplo n.º 12
0
        public virtual void testMigrateHistoryProcessInstance()
        {
            //given
            HistoricProcessInstanceQuery sourceHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);
            HistoricProcessInstanceQuery targetHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(targetProcessDefinition.Id);


            //when
            assertEquals(1, sourceHistoryProcessInstanceQuery.count());
            assertEquals(0, targetHistoryProcessInstanceQuery.count());
            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);

            runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();

            //then
            assertEquals(0, sourceHistoryProcessInstanceQuery.count());
            assertEquals(1, targetHistoryProcessInstanceQuery.count());

            HistoricProcessInstance instance = targetHistoryProcessInstanceQuery.singleResult();

            assertEquals(instance.ProcessDefinitionKey, targetProcessDefinition.Key);
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateWithIdVarargsArray()
        public virtual void testMigrateWithIdVarargsArray()
        {
            ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapEqualActivities().build();

            ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceDefinition.Id);
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceDefinition.Id);

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.Id, processInstance2.Id).execute();

            // then
            Assert.assertEquals(2, runtimeService.createProcessInstanceQuery().processDefinitionId(targetDefinition.Id).count());
        }