Search in sources :

Example 1 with MigrationReport

use of org.jbpm.services.api.admin.MigrationReport in project jbpm by kiegroup.

the class EMigrateProcessTest method testUpgradeProcessInstanceWithNodeMapping.

@Test
public void testUpgradeProcessInstanceWithNodeMapping() throws Exception {
    Long processInstanceId = processService.startProcess(kieJar, EVALUATION_PROCESS_ID_V1);
    if (processInstanceId != null) {
        archive.getPids().add(processInstanceId);
    }
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(1);
    TaskSummary task = tasks.get(0);
    Assertions.assertThat(tasks.get(0).getName()).isEqualTo("Evaluate items");
    Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar);
    Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V1);
    Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
    Map<String, String> nodeMapping = new HashMap<String, String>();
    nodeMapping.put("_4E8E7545-FB70-494E-9136-2B9ABE655889", "_56FB3E50-DEDD-415B-94DD-0357C91836B9");
    // migrate process instance to evaluation 2 in container 2
    MigrationReport report = migrationService.migrate(kieJar, processInstanceId, kieJar2, EVALUATION_PROCESS_ID_V2, nodeMapping);
    Assertions.assertThat(report).isNotNull();
    Assertions.assertThat(report.isSuccessful()).isTrue();
    // migrated to Approve user task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(1);
    task = tasks.get(0);
    Assertions.assertThat(task.getName()).isEqualTo("Approve");
    Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
    Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
    Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) MigrationReport(org.jbpm.services.api.admin.MigrationReport) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 2 with MigrationReport

use of org.jbpm.services.api.admin.MigrationReport in project jbpm by kiegroup.

the class ProcessInstanceMigrationServiceImplTest method testMigrateMultipleProcessInstances.

@Test
public void testMigrateMultipleProcessInstances() {
    List<Long> ids = new ArrayList<Long>();
    for (int i = 0; i < 5; i++) {
        long processInstanceId = processService.startProcess(deploymentUnitV1.getIdentifier(), ADDTASKAFTERACTIVE_ID_V1);
        assertNotNull(processInstanceId);
        ids.add(processInstanceId);
    }
    List<MigrationReport> reports = migrationService.migrate(deploymentUnitV1.getIdentifier(), ids, deploymentUnitV2.getIdentifier(), ADDTASKAFTERACTIVE_ID_V2);
    assertNotNull(reports);
    Iterator<MigrationReport> reportsIt = reports.iterator();
    for (Long processInstanceId : ids) {
        MigrationReport report = reportsIt.next();
        assertTrue(report.isSuccessful());
        assertMigratedProcessInstance(ADDTASKAFTERACTIVE_ID_V2, processInstanceId, ProcessInstance.STATE_ACTIVE);
        assertMigratedTaskAndComplete(ADDTASKAFTERACTIVE_ID_V2, processInstanceId, "Active Task");
        assertMigratedTaskAndComplete(ADDTASKAFTERACTIVE_ID_V2, processInstanceId, "Added Task");
        assertMigratedProcessInstance(ADDTASKAFTERACTIVE_ID_V2, processInstanceId, ProcessInstance.STATE_COMPLETED);
    }
}
Also used : ArrayList(java.util.ArrayList) MigrationReport(org.jbpm.services.api.admin.MigrationReport) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 3 with MigrationReport

use of org.jbpm.services.api.admin.MigrationReport in project jbpm by kiegroup.

the class EMigrateProcessTest method testUpgradeProcessInstance.

@Test
public void testUpgradeProcessInstance() throws Exception {
    Long processInstanceId = processService.startProcess(kieJar, EVALUATION_PROCESS_ID_V1);
    if (processInstanceId != null) {
        archive.getPids().add(processInstanceId);
    }
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(1);
    TaskSummary task = tasks.get(0);
    Assertions.assertThat(task.getName()).isEqualTo("Evaluate items");
    Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar);
    Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V1);
    Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
    // migrate process instance to evaluation 2 in container 2
    MigrationReport report = migrationService.migrate(kieJar, processInstanceId, kieJar2, EVALUATION_PROCESS_ID_V2);
    Assertions.assertThat(report).isNotNull();
    Assertions.assertThat(report.isSuccessful()).isTrue();
    // it stays in the same task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(1);
    task = tasks.get(0);
    Assertions.assertThat(task.getName()).isEqualTo("Evaluate items");
    Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
    Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
    Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
    userTaskService.completeAutoProgress(task.getId(), USER_YODA, null);
    // but next task should be Approve user task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(1);
    task = tasks.get(0);
    Assertions.assertThat(task.getName()).isEqualTo("Approve");
    Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
    Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
    Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) MigrationReport(org.jbpm.services.api.admin.MigrationReport) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 4 with MigrationReport

use of org.jbpm.services.api.admin.MigrationReport in project jbpm by kiegroup.

the class EMigrateProcessTest method testUpgradeProcessInstancesWithNodeMapping.

@Test
public void testUpgradeProcessInstancesWithNodeMapping() throws Exception {
    List<Long> ids = new ArrayList<Long>();
    for (int i = 0; i < 5; i++) {
        Long processInstanceId = processService.startProcess(kieJar, EVALUATION_PROCESS_ID_V1);
        ids.add(processInstanceId);
        if (processInstanceId != null) {
            archive.getPids().add(processInstanceId);
        }
    }
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(5);
    for (TaskSummary task : tasks) {
        Assertions.assertThat(task.getName()).isEqualTo("Evaluate items");
        Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar);
        Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V1);
    }
    Map<String, String> nodeMapping = new HashMap<String, String>();
    nodeMapping.put("_4E8E7545-FB70-494E-9136-2B9ABE655889", "_56FB3E50-DEDD-415B-94DD-0357C91836B9");
    // migrate process instance to evaluation 2 in container 2
    List<MigrationReport> reports = migrationService.migrate(kieJar, ids, kieJar2, EVALUATION_PROCESS_ID_V2, nodeMapping);
    Assertions.assertThat(reports).isNotNull();
    for (MigrationReport report : reports) {
        Assertions.assertThat(report.isSuccessful()).isTrue();
    }
    // but next task should be Approve user task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(5);
    for (TaskSummary task : tasks) {
        Assertions.assertThat(task.getName()).isEqualTo("Approve");
        Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
        Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
    }
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) MigrationReport(org.jbpm.services.api.admin.MigrationReport) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 5 with MigrationReport

use of org.jbpm.services.api.admin.MigrationReport in project jbpm by kiegroup.

the class EMigrateProcessTest method testUpgradeProcessInstances.

@Test
public void testUpgradeProcessInstances() throws Exception {
    List<Long> ids = new ArrayList<Long>();
    for (int i = 0; i < 5; i++) {
        Long processInstanceId = processService.startProcess(kieJar, EVALUATION_PROCESS_ID_V1);
        ids.add(processInstanceId);
        if (processInstanceId != null) {
            archive.getPids().add(processInstanceId);
        }
    }
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(5);
    for (TaskSummary task : tasks) {
        Assertions.assertThat(task.getName()).isEqualTo("Evaluate items");
        Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar);
        Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V1);
    }
    // migrate process instance to evaluation 2 in container 2
    List<MigrationReport> reports = migrationService.migrate(kieJar, ids, kieJar2, EVALUATION_PROCESS_ID_V2);
    Assertions.assertThat(reports).isNotNull();
    for (MigrationReport report : reports) {
        Assertions.assertThat(report.isSuccessful()).isTrue();
    }
    // it stays in the same task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(5);
    for (TaskSummary task : tasks) {
        Assertions.assertThat(task.getName()).isEqualTo("Evaluate items");
        Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
        Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
        userTaskService.completeAutoProgress(task.getId(), USER_YODA, null);
    }
    // but next task should be Approve user task
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
    Assertions.assertThat(tasks.size()).isEqualTo(5);
    for (TaskSummary task : tasks) {
        Assertions.assertThat(task.getName()).isEqualTo("Approve");
        Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
        Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
    }
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) MigrationReport(org.jbpm.services.api.admin.MigrationReport) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Aggregations

MigrationReport (org.jbpm.services.api.admin.MigrationReport)9 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)4 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)4 AbstractRuntimeEJBServicesTest (org.jbpm.test.container.AbstractRuntimeEJBServicesTest)4 TaskSummary (org.kie.api.task.model.TaskSummary)4 QueryFilter (org.kie.internal.query.QueryFilter)4