use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.
the class JobServiceIntegrationTest method testRunProcessAutoAckCommandRainyScenario.
@Test
public void testRunProcessAutoAckCommandRainyScenario() throws Exception {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_ROLLBACK);
assertNotNull(processInstanceId);
try {
completeTaskAndGenerateError();
runProcessAutoAckErrorCommand();
ExecutionErrorInstance error = getErrorByProcessId(processInstanceId);
// should not ack the job as it's in progress (did not finish)
assertFalse(error.isAcknowledged());
assertNull(error.getAcknowledgedAt());
assertNull(error.getAcknowledgedBy());
// ack error for cleaning up
processAdminClient.acknowledgeError(CONTAINER_ID, error.getErrorId());
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
use of org.kie.server.api.model.admin.ExecutionErrorInstance 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.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.
the class ProcessAdminServicesClientImpl method getError.
@Override
public ExecutionErrorInstance getError(String containerId, String errorId) {
ExecutionErrorInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(ERROR_ID, errorId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + ERROR_GET_URI, valuesMap), ExecutionErrorInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "getError", new Object[] { containerId, errorId })));
ServiceResponse<ExecutionErrorInstance> response = (ServiceResponse<ExecutionErrorInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminServicesClientImpl method getError.
@Override
public ExecutionErrorInstance getError(String containerId, String errorId) {
ExecutionErrorInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(ERROR_ID, errorId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + ERROR_GET_URI, valuesMap), ExecutionErrorInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskAdminService", "getError", new Object[] { errorId })));
ServiceResponse<ExecutionErrorInstance> response = (ServiceResponse<ExecutionErrorInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToErrorInstanceList.
public static ExecutionErrorInstanceList convertToErrorInstanceList(List<ExecutionError> executionErrors) {
if (executionErrors == null) {
return new ExecutionErrorInstanceList(new ExecutionErrorInstance[0]);
}
List<ExecutionErrorInstance> executionErrorInstances = new ArrayList<ExecutionErrorInstance>(executionErrors.size());
for (ExecutionError error : executionErrors) {
ExecutionErrorInstance errorInstance = convertToErrorInstance(error);
executionErrorInstances.add(errorInstance);
}
return new ExecutionErrorInstanceList(executionErrorInstances);
}
Aggregations