Search in sources :

Example 1 with ExecutionErrorInstance

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);
    }
}
Also used : ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance) Test(org.junit.Test)

Example 2 with ExecutionErrorInstance

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);
        }
    }
}
Also used : HashMap(java.util.HashMap) KieServicesException(org.kie.server.api.exception.KieServicesException) ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 3 with ExecutionErrorInstance

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;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance)

Example 4 with ExecutionErrorInstance

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;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance)

Example 5 with ExecutionErrorInstance

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);
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) ExecutionErrorInstanceList(org.kie.server.api.model.admin.ExecutionErrorInstanceList) ArrayList(java.util.ArrayList) ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance)

Aggregations

ExecutionErrorInstance (org.kie.server.api.model.admin.ExecutionErrorInstance)13 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 KieServicesException (org.kie.server.api.exception.KieServicesException)5 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)4 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Variant (javax.ws.rs.core.Variant)2 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)2 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)2 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)2 CommandScript (org.kie.server.api.commands.CommandScript)2 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)2 KieServerCommand (org.kie.server.api.model.KieServerCommand)2 ServiceResponse (org.kie.server.api.model.ServiceResponse)2 Header (org.kie.server.remote.rest.common.Header)2 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)2