use of org.kie.server.api.exception.KieServicesException 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.exception.KieServicesException 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.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminServiceIntegrationTest method testErrorHandling.
@Test
public void testErrorHandling() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("nullAccepted", false);
Long processInstanceId = null;
try {
processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_SIGNAL_PROCESS, parameters);
List<ExecutionErrorInstance> errors = processAdminClient.getErrors(CONTAINER_ID, false, 0, 10);
assertNotNull(errors);
assertEquals(0, errors.size());
try {
processClient.signalProcessInstance(CONTAINER_ID, processInstanceId, "Signal1", null);
fail("Process instance signal fail as it provides null as event");
} catch (KieServicesException e) {
// expected
}
errors = processAdminClient.getErrorsByProcessInstance(CONTAINER_ID, processInstanceId, false, 0, 10);
assertNotNull(errors);
assertEquals(1, errors.size());
ExecutionErrorInstance errorInstance = errors.get(0);
assertNotNull(errorInstance.getErrorId());
assertNull(errorInstance.getError());
assertNotNull(errorInstance.getProcessInstanceId());
assertNotNull(errorInstance.getActivityId());
assertNotNull(errorInstance.getErrorDate());
assertEquals(CONTAINER_ID, errorInstance.getContainerId());
assertEquals(PROCESS_ID_SIGNAL_PROCESS, errorInstance.getProcessId());
assertEquals("Signal 1 data", errorInstance.getActivityName());
assertFalse(errorInstance.isAcknowledged());
assertNull(errorInstance.getAcknowledgedAt());
assertNull(errorInstance.getAcknowledgedBy());
userTaskAdminClient.acknowledgeError(CONTAINER_ID, errorInstance.getErrorId());
errorInstance = userTaskAdminClient.getError(CONTAINER_ID, errorInstance.getErrorId());
assertNotNull(errorInstance);
assertNotNull(errorInstance.getErrorId());
assertTrue(errorInstance.isAcknowledged());
assertNotNull(errorInstance.getAcknowledgedAt());
assertEquals(USER_YODA, errorInstance.getAcknowledgedBy());
} catch (KieServicesException e) {
logger.error("Unexpected error", e);
fail(e.getMessage());
} finally {
if (processInstanceId != null) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
}
use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class OptaplannerIntegrationTest method testCreateDuplicitSolver.
@Test
public void testCreateDuplicitSolver() {
SolverInstance solverInstance = solverClient.createSolver(CONTAINER_1_ID, SOLVER_1_ID, SOLVER_1_CONFIG);
assertNotNull(solverInstance);
try {
solverClient.createSolver(CONTAINER_1_ID, SOLVER_1_ID, SOLVER_1_CONFIG);
fail("A KieServicesException should have been thrown by now.");
} catch (KieServicesException e) {
KieServerAssert.assertResultContainsStringRegex(e.getMessage(), ".*Failed to create solver. Solver .* already exists for container .*");
}
}
use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.
the class OptaplannerIntegrationTest method testExecuteRunningSolver.
@Test
public void testExecuteRunningSolver() throws Exception {
SolverInstance solverInstance = solverClient.createSolver(CONTAINER_1_ID, SOLVER_1_ID, SOLVER_1_CONFIG);
assertNotNull(solverInstance);
assertEquals(SolverInstance.SolverStatus.NOT_SOLVING, solverInstance.getStatus());
// start solver
Object planningProblem = loadPlanningProblem(5, 15);
solverClient.solvePlanningProblem(CONTAINER_1_ID, SOLVER_1_ID, planningProblem);
// start solver again
try {
solverClient.solvePlanningProblem(CONTAINER_1_ID, SOLVER_1_ID, planningProblem);
fail("A KieServicesException should have been thrown by now.");
} catch (KieServicesException e) {
KieServerAssert.assertResultContainsStringRegex(e.getMessage(), ".*Solver .* on container .* is already executing.*");
}
solverClient.disposeSolver(CONTAINER_1_ID, SOLVER_1_ID);
}
Aggregations