Search in sources :

Example 16 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class ProcessInstanceAdminServiceImpl method getError.

@Override
public ExecutionError getError(String errorId) throws ExecutionErrorNotFoundException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("errorId", errorId);
    List<ExecutionError> execErrors = commandService.execute(new QueryNameCommand<List<ExecutionError>>("getErrorByIdSkipAckCheck", params));
    if (execErrors.isEmpty()) {
        throw new ExecutionErrorNotFoundException("No execution error found for id " + errorId);
    }
    ExecutionError error = execErrors.get(0);
    return error;
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) HashMap(java.util.HashMap) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class UserTaskAdminServiceImpl method getError.

@Override
public ExecutionError getError(String errorId) throws ExecutionErrorNotFoundException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("errorId", errorId);
    List<ExecutionError> execErrors = commandService.execute(new QueryNameCommand<List<ExecutionError>>("getErrorByIdSkipAckCheck", params));
    if (execErrors.isEmpty()) {
        throw new ExecutionErrorNotFoundException("No execution error found for id " + errorId);
    }
    ExecutionError error = execErrors.get(0);
    return error;
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) HashMap(java.util.HashMap) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class ExecutionErrorQueryMapper method map.

@Override
public List<ExecutionError> map(Object result) {
    if (result instanceof DataSet) {
        DataSet dataSetResult = (DataSet) result;
        List<ExecutionError> mappedResult = new ArrayList<ExecutionError>();
        if (dataSetResult != null) {
            for (int i = 0; i < dataSetResult.getRowCount(); i++) {
                ExecutionError pi = buildInstance(dataSetResult, i);
                mappedResult.add(pi);
            }
        }
        return mappedResult;
    }
    throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) DataSet(org.dashbuilder.dataset.DataSet) ArrayList(java.util.ArrayList)

Example 19 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class ExecutionErrorHandlingRuntimeManagerTest method testBasicScriptFailure.

@Test
public void testBasicScriptFailure() {
    RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession1 = runtime1.getKieSession();
    assertNotNull(ksession1);
    try {
        ksession1.startProcess("BrokenScriptTask");
        fail("Start process should fail due to broken script");
    } catch (Throwable e) {
    // expected
    }
    manager.disposeRuntimeEngine(runtime1);
    ExecutionErrorManager errorManager = ((AbstractRuntimeManager) manager).getExecutionErrorManager();
    ExecutionErrorStorage storage = errorManager.getStorage();
    List<ExecutionError> errors = storage.list(0, 10);
    assertNotNull(errors);
    assertEquals(1, errors.size());
    assertExecutionError(errors.get(0), "Process", "BrokenScriptTask", "Hello");
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionError(org.kie.internal.runtime.error.ExecutionError) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ExecutionErrorStorage(org.kie.internal.runtime.error.ExecutionErrorStorage) KieSession(org.kie.api.runtime.KieSession) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Example 20 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class ExecutionErrorHandlingRuntimeManagerTest method testFailureAfterUserTaskNoWorkItemHandler.

@Test
public void testFailureAfterUserTaskNoWorkItemHandler() {
    RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession1 = runtime1.getKieSession();
    assertNotNull(ksession1);
    ProcessInstance pi = ksession1.startProcess("UserTaskWithCustomTask");
    manager.disposeRuntimeEngine(runtime1);
    runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(pi.getId()));
    ksession1 = runtime1.getKieSession();
    TaskService taskService = runtime1.getTaskService();
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
    assertEquals(1, tasks.size());
    long taskId = tasks.get(0).getId();
    taskService.start(taskId, "john");
    Map<String, Object> results = new HashMap<>();
    results.put("output1", "rollback");
    try {
        taskService.complete(taskId, "john", results);
        fail("Complete task should fail due to no work item handler found error");
    } catch (Throwable e) {
    // expected
    }
    manager.disposeRuntimeEngine(runtime1);
    ExecutionErrorManager errorManager = ((AbstractRuntimeManager) manager).getExecutionErrorManager();
    ExecutionErrorStorage storage = errorManager.getStorage();
    List<ExecutionError> errors = storage.list(0, 10);
    assertNotNull(errors);
    assertEquals(1, errors.size());
    assertExecutionError(errors.get(0), "Process", "UserTaskWithCustomTask", "Manual Task 2");
    String errorMessage = errors.get(0).getErrorMessage();
    assertTrue(errorMessage.contains("Could not find work item handler for Manual Task"));
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionError(org.kie.internal.runtime.error.ExecutionError) HashMap(java.util.HashMap) TaskService(org.kie.api.task.TaskService) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) TaskSummary(org.kie.api.task.model.TaskSummary) ExecutionErrorStorage(org.kie.internal.runtime.error.ExecutionErrorStorage) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Aggregations

ExecutionError (org.kie.internal.runtime.error.ExecutionError)22 Test (org.junit.Test)14 ExecutionErrorStorage (org.kie.internal.runtime.error.ExecutionErrorStorage)14 KieSession (org.kie.api.runtime.KieSession)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)13 AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10 ExecutionErrorManager (org.kie.internal.runtime.error.ExecutionErrorManager)10 HashMap (java.util.HashMap)9 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)8 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)8 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 TaskService (org.kie.api.task.TaskService)5 TaskSummary (org.kie.api.task.model.TaskSummary)5 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)4 QueryContext (org.kie.api.runtime.query.QueryContext)4