Search in sources :

Example 1 with ProcessErrors

use of io.automatiko.engine.api.workflow.ProcessErrors in project automatiko-engine by automatiko-io.

the class BaseProcessInstanceManagementResource method doGetInstanceInError.

public T doGetInstanceInError(String processId, String processInstanceId) {
    return executeOnInstanceInError(processId, processInstanceId, processInstance -> {
        ProcessErrors errors = processInstance.errors().get();
        List<Map<String, String>> errorsData = new ArrayList<>();
        for (ProcessError error : errors.errors()) {
            Map<String, String> data = new HashMap<>();
            data.put("id", processInstance.id());
            data.put("failedNodeId", error.failedNodeId());
            data.put("message", error.errorMessage());
            errorsData.add(data);
        }
        return buildOkResponse(errorsData);
    });
}
Also used : ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) ProcessError(io.automatiko.engine.api.workflow.ProcessError) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with ProcessErrors

use of io.automatiko.engine.api.workflow.ProcessErrors in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testServiceProcessDifferentOperationsParallelTaskRetriggerIndividually.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testServiceProcessDifferentOperationsParallelTaskRetriggerIndividually() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessDifferentOperationsParallel.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ServiceProcessDifferentOperations_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    // parameters.put("s", "john");
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.startDate()).isNotNull();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
    assertThat(processInstance.errors()).isPresent();
    assertThat(((ProcessErrors) processInstance.errors().get()).errors()).hasSize(2);
    parameters.put("s", "john");
    m.fromMap(parameters);
    processInstance.updateVariables(m);
    ProcessErrors errors = (ProcessErrors) processInstance.errors().get();
    for (ProcessError error : errors.errors()) {
        errors.retrigger(error.failedNodeId());
    }
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("s");
    assertThat(result.toMap().get("s")).isNotNull().asString().contains("Goodbye").contains("Hello");
}
Also used : ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) HashMap(java.util.HashMap) ProcessError(io.automatiko.engine.api.workflow.ProcessError) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessErrors

use of io.automatiko.engine.api.workflow.ProcessErrors in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testServiceProcessDifferentOperationsParallelTask.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testServiceProcessDifferentOperationsParallelTask() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessDifferentOperationsParallel.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ServiceProcessDifferentOperations_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    // parameters.put("s", "john");
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.startDate()).isNotNull();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
    assertThat(processInstance.errors()).isPresent();
    assertThat(((ProcessErrors) processInstance.errors().get()).errors()).hasSize(2);
    parameters.put("s", "john");
    m.fromMap(parameters);
    processInstance.updateVariables(m);
    ((ProcessErrors) processInstance.errors().get()).retrigger();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("s");
    assertThat(result.toMap().get("s")).isNotNull().asString().contains("Goodbye").contains("Hello");
}
Also used : ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessErrors

use of io.automatiko.engine.api.workflow.ProcessErrors in project automatiko-engine by automatiko-io.

the class ServiceTaskTest method testServiceProcessDifferentOperationsParallelTaskSkip.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testServiceProcessDifferentOperationsParallelTaskSkip() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessDifferentOperationsParallel.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ServiceProcessDifferentOperations_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.startDate()).isNotNull();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
    assertThat(processInstance.errors()).isPresent();
    assertThat(((ProcessErrors) processInstance.errors().get()).errors()).hasSize(2);
    parameters.put("s", "john");
    m.fromMap(parameters);
    processInstance.updateVariables(m);
    ((ProcessErrors) processInstance.errors().get()).skip();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("s");
    assertThat(result.toMap().get("s")).isNotNull().isEqualTo("john");
}
Also used : ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessErrors

use of io.automatiko.engine.api.workflow.ProcessErrors in project automatiko-engine by automatiko-io.

the class PublishEventTest method testServiceTaskProcessWithError.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testServiceTaskProcessWithError() throws Exception {
    Application app = generateCodeProcessesOnly("servicetask/ServiceProcessDifferentOperations.bpmn2");
    assertThat(app).isNotNull();
    TestEventPublisher publisher = new TestEventPublisher();
    app.unitOfWorkManager().eventManager().setService("http://myhost");
    app.unitOfWorkManager().eventManager().addPublisher(publisher);
    UnitOfWork uow = app.unitOfWorkManager().newUnitOfWork();
    uow.start();
    Process<? extends Model> p = app.processes().processById("ServiceProcessDifferentOperations_1_0");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);
    ProcessInstance processInstance = p.createInstance(m);
    processInstance.start();
    uow.end();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
    List<DataEvent<?>> events = publisher.extract();
    assertThat(events).isNotNull().hasSize(1);
    ProcessInstanceEventBody body = assertProcessInstanceEvent(events.get(0), "ServiceProcessDifferentOperations", "Service Process", 5);
    assertThat(body.getNodeInstances()).hasSize(2).extractingResultOf("getNodeType").contains("StartNode", "WorkItemNode");
    assertThat(body.getNodeInstances()).extractingResultOf("getTriggerTime").allMatch(v -> v != null);
    // human task is active
    assertThat(body.getNodeInstances()).extractingResultOf("getLeaveTime").containsNull();
    // thus null for leave
    // time
    assertThat(body.getErrors()).hasSize(1);
    assertThat(body.getErrors().get(0).getNodeDefinitionId()).isEqualTo("_38E04E27-3CCA-47F9-927B-E37DC4B8CE25");
    parameters.put("s", "john");
    m.fromMap(parameters);
    uow = app.unitOfWorkManager().newUnitOfWork();
    uow.start();
    processInstance.updateVariables(m);
    uow.end();
    events = publisher.extract();
    assertThat(events).isNotNull().hasSize(1);
    body = assertProcessInstanceEvent(events.get(0), "ServiceProcessDifferentOperations", "Service Process", 5);
    assertThat(body.getErrors()).hasSize(1);
    assertThat(body.getErrors().get(0).getNodeDefinitionId()).isEqualTo("_38E04E27-3CCA-47F9-927B-E37DC4B8CE25");
    uow = app.unitOfWorkManager().newUnitOfWork();
    uow.start();
    if (processInstance.errors().isPresent()) {
        ((ProcessErrors) processInstance.errors().get()).retrigger();
    }
    uow.end();
    events = publisher.extract();
    assertThat(events).isNotNull().hasSize(1);
    body = assertProcessInstanceEvent(events.get(0), "ServiceProcessDifferentOperations", "Service Process", 2);
    assertThat(body.getErrors()).isEmpty();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("s");
    assertThat(result.toMap().get("s")).isNotNull().isEqualTo("Goodbye Hello john!!");
}
Also used : UnitOfWork(io.automatiko.engine.api.uow.UnitOfWork) HashMap(java.util.HashMap) ProcessInstanceEventBody(io.automatiko.engine.services.event.impl.ProcessInstanceEventBody) DataEvent(io.automatiko.engine.api.event.DataEvent) UserTaskInstanceDataEvent(io.automatiko.engine.services.event.UserTaskInstanceDataEvent) ProcessInstanceDataEvent(io.automatiko.engine.services.event.ProcessInstanceDataEvent) ProcessErrors(io.automatiko.engine.api.workflow.ProcessErrors) Model(io.automatiko.engine.api.Model) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessErrors (io.automatiko.engine.api.workflow.ProcessErrors)7 HashMap (java.util.HashMap)5 Test (org.junit.jupiter.api.Test)5 Application (io.automatiko.engine.api.Application)4 Model (io.automatiko.engine.api.Model)4 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)4 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)4 ProcessError (io.automatiko.engine.api.workflow.ProcessError)3 Map (java.util.Map)2 DataEvent (io.automatiko.engine.api.event.DataEvent)1 UnitOfWork (io.automatiko.engine.api.uow.UnitOfWork)1 ExecutionsErrorInfo (io.automatiko.engine.api.workflow.ExecutionsErrorInfo)1 ProcessInstanceDataEvent (io.automatiko.engine.services.event.ProcessInstanceDataEvent)1 UserTaskInstanceDataEvent (io.automatiko.engine.services.event.UserTaskInstanceDataEvent)1 ProcessInstanceEventBody (io.automatiko.engine.services.event.impl.ProcessInstanceEventBody)1 NodeInstance (io.automatiko.engine.workflow.process.instance.NodeInstance)1 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)1 CompositeContextNodeInstance (io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance)1 EventSubProcessNodeInstance (io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance)1 HumanTaskNodeInstance (io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance)1