use of io.automatiko.engine.api.workflow.ProcessInstance in project automatiko-engine by automatiko-io.
the class FileSystemProcessInstances method importInstance.
@Override
public ProcessInstance importInstance(ExportedProcessInstance instance, Process process) {
ProcessInstance imported = marshaller.importProcessInstance(instance, process);
if (exists(imported.id())) {
throw new ProcessInstanceDuplicatedException(imported.id());
}
create(imported.id(), imported);
return imported;
}
use of io.automatiko.engine.api.workflow.ProcessInstance 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.ProcessInstance 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.ProcessInstance in project automatiko-engine by automatiko-io.
the class ServiceTaskTest method testBasicServiceProcessTaskWithRetrySuccessful.
@Test
@Timeout(unit = TimeUnit.SECONDS, value = 10000)
public void testBasicServiceProcessTaskWithRetrySuccessful() throws Exception {
Application app = generateCodeProcessesOnly("servicetask/ServiceProcessRetry.bpmn2");
assertThat(app).isNotNull();
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("EndProcess", 1);
((DefaultProcessEventListenerConfig) app.config().process().processEventListeners()).register(listener);
Process<? extends Model> p = app.processes().processById("ServiceProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
parameters.put("s", "john");
m.fromMap(parameters);
ProcessInstance processInstance = p.createInstance(m);
processInstance.start();
m.fromMap(Collections.singletonMap("s", "mary"));
processInstance.updateVariables(m);
listener.waitTillCompleted();
assertThat(processInstance.startDate()).isNotNull();
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("Hello mary!");
}
use of io.automatiko.engine.api.workflow.ProcessInstance 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");
}
Aggregations