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);
});
}
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");
}
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");
}
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");
}
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!!");
}
Aggregations