Search in sources :

Example 6 with ExecutionErrorInstance

use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.

the class QueryDataServiceIntegrationTest method testErrorHandlingFailedToSignal.

@Test
public void testErrorHandlingFailedToSignal() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("nullAccepted", false);
    QueryDefinition query = createErrorsQueryDefinition();
    Long processInstanceId = null;
    try {
        queryClient.registerQuery(query);
        processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_SIGNAL_PROCESS, parameters);
        List<ExecutionErrorInstance> errors = processAdminClient.getErrorsByProcessInstance(CONTAINER_ID, processInstanceId, false, 0, 10);
        assertNotNull(errors);
        assertEquals(0, errors.size());
        try {
            processClient.signalProcessInstance(CONTAINER_ID, processInstanceId, "Signal1", null);
            fail("Process instance signal should fail as it provides null as event");
        } catch (KieServicesException e) {
        // expected
        }
        errors = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_ERROR, 0, 10, ExecutionErrorInstance.class);
        errors = filterErrorsByProcessInstanceId(errors, processInstanceId);
        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());
        errors = processAdminClient.getErrorsByProcessInstanceAndNode(CONTAINER_ID, processInstanceId, "Signal 1 data", false, 0, 10);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        ExecutionErrorInstance errorInstance2 = errors.get(0);
        assertEquals(errorInstance.getErrorId(), errorInstance2.getErrorId());
        processAdminClient.acknowledgeError(CONTAINER_ID, errorInstance.getErrorId());
        errors = processAdminClient.getErrorsByProcessInstance(CONTAINER_ID, processInstanceId, false, 0, 10);
        assertNotNull(errors);
        assertEquals(0, errors.size());
        errorInstance = processAdminClient.getError(CONTAINER_ID, errorInstance.getErrorId());
        assertNotNull(errorInstance);
        assertNotNull(errorInstance.getErrorId());
        assertTrue(errorInstance.isAcknowledged());
        assertNotNull(errorInstance.getAcknowledgedAt());
        assertEquals(USER_YODA, errorInstance.getAcknowledgedBy());
    } catch (Exception e) {
        logger.error("Unexpected error", e);
        fail(e.getMessage());
    } finally {
        queryClient.unregisterQuery(query.getName());
        if (processInstanceId != null) {
            processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
        }
    }
}
Also used : QueryDefinition(org.kie.server.api.model.definition.QueryDefinition) HashMap(java.util.HashMap) KieServicesException(org.kie.server.api.exception.KieServicesException) KieServicesException(org.kie.server.api.exception.KieServicesException) ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance) Test(org.junit.Test)

Example 7 with ExecutionErrorInstance

use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.

the class JobServiceIntegrationTest method getErrorByProcessId.

private ExecutionErrorInstance getErrorByProcessId(Long processInstanceId) {
    List<ExecutionErrorInstance> errors = processAdminClient.getErrorsByProcessInstance(CONTAINER_ID, processInstanceId, true, 0, 10);
    assertEquals(1, errors.size());
    ExecutionErrorInstance error = errors.get(0);
    assertNotNull(error);
    return error;
}
Also used : ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance)

Example 8 with ExecutionErrorInstance

use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.

the class JobServiceIntegrationTest method testRunProcessAutoAckCommandSunnyScenario.

@Test
public void testRunProcessAutoAckCommandSunnyScenario() throws Exception {
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK_WITH_ROLLBACK);
    assertNotNull(processInstanceId);
    completeTaskAndGenerateError();
    completeTaskWithoutError();
    runProcessAutoAckErrorCommand();
    ExecutionErrorInstance error = getErrorByProcessId(processInstanceId);
    // since task was completed auto ack should work
    assertTrue(error.isAcknowledged());
    assertNotNull(error.getAcknowledgedAt());
    assertNotNull(error.getAcknowledgedBy());
}
Also used : ExecutionErrorInstance(org.kie.server.api.model.admin.ExecutionErrorInstance) Test(org.junit.Test)

Example 9 with ExecutionErrorInstance

use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceAdminServiceIntegrationTest method testErrorHandlingFailedToStart.

@Test
public void testErrorHandlingFailedToStart() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("timer", "invalid value");
    try {
        processClient.startProcess(CONTAINER_ID, PROCESS_ID_TIMER, parameters);
        fail("Process instance should fail as it has invalid timer expression");
    } catch (KieServicesException e) {
    // expected as the variable to configure timer duration is invalid
    }
    List<ExecutionErrorInstance> errors = processAdminClient.getErrors(CONTAINER_ID, false, 0, 10);
    errors = filterErrorsByProcessId(errors, PROCESS_ID_TIMER);
    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_TIMER, errorInstance.getProcessId());
    assertEquals("timer", errorInstance.getActivityName());
    assertFalse(errorInstance.isAcknowledged());
    assertNull(errorInstance.getAcknowledgedAt());
    assertNull(errorInstance.getAcknowledgedBy());
    processAdminClient.acknowledgeError(CONTAINER_ID, errorInstance.getErrorId());
    errors = processAdminClient.getErrors(CONTAINER_ID, false, 0, 10);
    errors = filterErrorsByProcessId(errors, PROCESS_ID_TIMER);
    assertNotNull(errors);
    assertEquals(0, errors.size());
    errorInstance = processAdminClient.getError(CONTAINER_ID, errorInstance.getErrorId());
    assertNotNull(errorInstance);
    assertNotNull(errorInstance.getErrorId());
    assertTrue(errorInstance.isAcknowledged());
    assertNotNull(errorInstance.getAcknowledgedAt());
    assertEquals(USER_YODA, errorInstance.getAcknowledgedBy());
}
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 10 with ExecutionErrorInstance

use of org.kie.server.api.model.admin.ExecutionErrorInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceAdminServiceIntegrationTest method testErrorHandlingFailedToStartBulkAck.

@Test
public void testErrorHandlingFailedToStartBulkAck() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("timer", "invalid value");
    try {
        processClient.startProcess(CONTAINER_ID, PROCESS_ID_TIMER, parameters);
        fail("Process instance should fail as it has invalid timer expression");
    } catch (KieServicesException e) {
    // expected as the variable to configure timer duration is invalid
    }
    try {
        processClient.startProcess(CONTAINER_ID, PROCESS_ID_TIMER, parameters);
        fail("Process instance should fail as it has invalid timer expression");
    } catch (KieServicesException e) {
    // expected as the variable to configure timer duration is invalid
    }
    List<ExecutionErrorInstance> errors = processAdminClient.getErrors(CONTAINER_ID, false, 0, 10);
    errors = filterErrorsByProcessId(errors, PROCESS_ID_TIMER);
    assertNotNull(errors);
    assertEquals(2, errors.size());
    ExecutionErrorInstance errorInstance = errors.get(0);
    assertFalse(errorInstance.isAcknowledged());
    assertNull(errorInstance.getAcknowledgedAt());
    assertNull(errorInstance.getAcknowledgedBy());
    ExecutionErrorInstance errorInstance2 = errors.get(1);
    assertFalse(errorInstance2.isAcknowledged());
    assertNull(errorInstance2.getAcknowledgedAt());
    assertNull(errorInstance2.getAcknowledgedBy());
    processAdminClient.acknowledgeError(CONTAINER_ID, errorInstance.getErrorId(), errorInstance2.getErrorId());
    errors = processAdminClient.getErrors(CONTAINER_ID, false, 0, 10);
    errors = filterErrorsByProcessId(errors, PROCESS_ID_TIMER);
    assertNotNull(errors);
    assertEquals(0, errors.size());
    errorInstance = processAdminClient.getError(CONTAINER_ID, errorInstance.getErrorId());
    assertNotNull(errorInstance);
    assertNotNull(errorInstance.getErrorId());
    assertTrue(errorInstance.isAcknowledged());
    assertNotNull(errorInstance.getAcknowledgedAt());
    assertEquals(USER_YODA, errorInstance.getAcknowledgedBy());
}
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)

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