Search in sources :

Example 11 with ExecutionErrorManager

use of org.kie.internal.runtime.error.ExecutionErrorManager 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 12 with ExecutionErrorManager

use of org.kie.internal.runtime.error.ExecutionErrorManager 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

AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)12 ExecutionErrorManager (org.kie.internal.runtime.error.ExecutionErrorManager)12 Test (org.junit.Test)10 KieSession (org.kie.api.runtime.KieSession)10 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)10 ExecutionError (org.kie.internal.runtime.error.ExecutionError)10 ExecutionErrorStorage (org.kie.internal.runtime.error.ExecutionErrorStorage)10 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)7 HashMap (java.util.HashMap)5 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)5 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)5 TaskService (org.kie.api.task.TaskService)5 TaskSummary (org.kie.api.task.model.TaskSummary)5 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)4 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)3 TaskExecutionException (org.jbpm.services.task.exception.TaskExecutionException)3 CommandContext (org.kie.api.executor.CommandContext)3 RequestInfo (org.kie.api.executor.RequestInfo)3