use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertReports.
public static MigrationReportInstance[] convertReports(List<MigrationReport> entries) {
MigrationReportInstance[] reports = new MigrationReportInstance[entries.size()];
int counter = 0;
if (entries != null) {
for (MigrationReport entry : entries) {
reports[counter++] = convertMigrationReport(entry);
}
}
return reports;
}
use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstanceWithNodeMapping.
@Test
public void testUpgradeProcessInstanceWithNodeMapping() {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
try {
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertEquals("Evaluate items?", tasks.get(0).getName());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
assertEquals(processInstanceId, task.getProcessInstanceId());
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
MigrationReportInstance report = processAdminClient.migrateProcessInstance(CONTAINER_ID, processInstanceId, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2, nodeMapping);
assertNotNull(report);
assertTrue(report.isSuccessful());
// migrated to Approve user task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
task = tasks.get(0);
assertEquals("Approve", task.getName());
assertEquals(CONTAINER_ID_2, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
assertEquals(processInstanceId, task.getProcessInstanceId());
} finally {
try {
processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
} catch (KieServicesException e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
}
use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstance.
@Test
public void testUpgradeProcessInstance() {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
try {
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
TaskSummary task = tasks.get(0);
assertEquals("Evaluate items?", tasks.get(0).getName());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
assertEquals(processInstanceId, task.getProcessInstanceId());
// migrate process instance to evaluation 2 in container 2
MigrationReportInstance report = processAdminClient.migrateProcessInstance(CONTAINER_ID, processInstanceId, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2);
assertNotNull(report);
assertTrue(report.isSuccessful());
// it stays in the same task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
task = tasks.get(0);
assertEquals("Evaluate items?", task.getName());
assertEquals(CONTAINER_ID_2, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
assertEquals(processInstanceId, task.getProcessInstanceId());
taskClient.completeAutoProgress(CONTAINER_ID_2, task.getId(), USER_YODA, null);
// but next task should be Approve user task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
task = tasks.get(0);
assertEquals("Approve", task.getName());
assertEquals(CONTAINER_ID_2, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
assertEquals(processInstanceId, task.getProcessInstanceId());
} finally {
try {
processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
} catch (KieServicesException e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
}
use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstances.
@Test
public void testUpgradeProcessInstances() {
List<Long> ids = new ArrayList<Long>();
for (int i = 0; i < 5; i++) {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
ids.add(processInstanceId);
}
try {
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(5, tasks.size());
for (TaskSummary task : tasks) {
assertEquals("Evaluate items?", tasks.get(0).getName());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
}
// migrate process instance to evaluation 2 in container 2
List<MigrationReportInstance> reports = processAdminClient.migrateProcessInstances(CONTAINER_ID, ids, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2);
assertNotNull(reports);
assertEquals(5, reports.size());
for (MigrationReportInstance report : reports) {
assertTrue(report.isSuccessful());
}
// it stays in the same task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(5, tasks.size());
for (TaskSummary task : tasks) {
assertEquals("Evaluate items?", tasks.get(0).getName());
assertEquals(CONTAINER_ID_2, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
taskClient.completeAutoProgress(CONTAINER_ID_2, task.getId(), USER_YODA, null);
}
// but next task should be Approve user task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(5, tasks.size());
for (TaskSummary task : tasks) {
assertEquals("Approve", task.getName());
assertEquals(CONTAINER_ID_2, task.getContainerId());
assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
}
} finally {
for (Long processInstanceId : ids) {
try {
processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
} catch (KieServicesException e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
}
}
use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceMigrationIntegrationTest method assertMigrateProcessInstanceWithSubprocess.
private void assertMigrateProcessInstanceWithSubprocess(Long processParentInstanceId, String sourceContainerId, String targetContainerId, MigrationSpecification spec, int totalMigratedInstances) {
List<MigrationReportInstance> reports = processAdminClient.migrateProcessInstanceWithSubprocess(sourceContainerId, processParentInstanceId, targetContainerId, spec);
assertNotNull(reports);
for (MigrationReportInstance report : reports) {
assertTrue(report.isSuccessful());
}
logger.info("process migration complete in container {} with id parent {}", targetContainerId, processParentInstanceId);
assertEquals(totalMigratedInstances, reports.size());
}
Aggregations