use of io.takari.bpm.api.ExecutionException in project concord by walmartlabs.
the class YamlParserTest method test061.
@Test
public void test061() {
deploy("061.yml");
MyLogger task = spy(new MyLogger());
register("__withItemsUtils", new StepConverter.WithItemsUtilsTask());
register("myLogger", task);
// ---
String key = UUID.randomUUID().toString();
Map<String, Object> args = new HashMap<>();
args.put("notArrayVariable", "invalid variable type");
try {
start(key, "main", args);
fail("exception expected");
} catch (ExecutionException e) {
assertTrue(e.getCause().getCause().getMessage().contains("should be a list"));
}
}
use of io.takari.bpm.api.ExecutionException in project concord by walmartlabs.
the class YamlParserTest method test021_2.
@Test
public void test021_2() throws Exception {
deploy("021_2.yml");
ProcessDefinition pd = getDefinition("main");
// /--> task ---------> end
// start -> gw -> task -> task -> end
assertEquals(13, pd.getChildren().size());
TestBean testBean = spy(new TestBean());
register("testBean", testBean);
// ---
String key = UUID.randomUUID().toString();
Map<String, Object> args = Collections.singletonMap("aInt", -100);
try {
start(key, "main", args);
fail("exception expected");
} catch (ExecutionException e) {
assertTrue(e.getMessage().contains("error-code-2"));
}
// ---
verify(testBean, times(1)).toString(eq("b"));
verifyNoMoreInteractions(testBean);
}
use of io.takari.bpm.api.ExecutionException in project concord by walmartlabs.
the class YamlParserTest method test022_2.
@Test
public void test022_2() throws Exception {
deploy("022_2.yml");
ProcessDefinition pd = getDefinition("main");
// /--> task ---------> end
// start -> gw -> task -> task -> end
assertEquals(13, pd.getChildren().size());
TestBean testBean = spy(new TestBean());
register("testBean", testBean);
// ---
String key = UUID.randomUUID().toString();
Map<String, Object> args = Collections.singletonMap("aInt", 100);
try {
start(key, "main", args);
fail("exception expected");
} catch (ExecutionException e) {
assertTrue(e.getMessage().contains("error-code"));
}
// ---
verify(testBean, times(1)).toString(eq("a"));
verifyNoMoreInteractions(testBean);
}
use of io.takari.bpm.api.ExecutionException in project concord by walmartlabs.
the class DefaultElementEventProcessor method process.
@Override
public void process(ElementEvent event, EventParamsBuilder builder, Predicate<AbstractElement> filter) throws ExecutionException {
ProcessDefinition pd = processDefinitionProvider.getById(event.getProcessDefinitionId());
if (pd == null) {
throw new RuntimeException("Process definition not found: " + event.getProcessDefinitionId());
}
if (!(pd instanceof SourceAwareProcessDefinition)) {
return;
}
Map<String, SourceMap> sourceMaps = ((SourceAwareProcessDefinition) pd).getSourceMaps();
SourceMap source = sourceMaps.get(event.getElementId());
if (source == null) {
return;
}
AbstractElement element = ProcessDefinitionUtils.findElement(pd, event.getElementId());
if (filter != null && !filter.test(element)) {
return;
}
try {
Map<String, Object> e = new HashMap<>();
e.put("processDefinitionId", event.getProcessDefinitionId());
e.put("elementId", event.getElementId());
e.put("line", source.getLine());
e.put("column", source.getColumn());
e.put("description", source.getDescription());
e.putAll(builder.build(element));
ProcessEventRequest req = new ProcessEventRequest();
// TODO should it be in the constants?
req.setEventType("ELEMENT");
req.setData(e);
req.setEventDate(Instant.now().atOffset(ZoneOffset.UTC));
ProcessEventsApi client = new ProcessEventsApi(apiClientFactory.create(ApiClientConfiguration.builder().sessionToken(event.getSessionToken()).txId(UUID.fromString(event.getInstanceId())).build()));
client.event(UUID.fromString(event.getInstanceId()), req);
} catch (Exception e) {
log.warn("process ['{}'] -> transfer error: {}", event.getInstanceId(), e.getMessage());
}
}
use of io.takari.bpm.api.ExecutionException in project concord by walmartlabs.
the class FileFormStorage method save.
@Override
public void save(Form form) throws ExecutionException {
UUID id = form.getFormInstanceId();
Path p = dir.resolve(form.getFormDefinition().getName());
try {
Path tmp = IOUtils.createTempFile(id.toString(), "form");
try (OutputStream out = Files.newOutputStream(tmp)) {
SerializationUtils.serialize(out, form);
}
Files.move(tmp, p, REPLACE_EXISTING);
} catch (IOException e) {
throw new ExecutionException("Error while saving a form", e);
}
}
Aggregations