use of io.takari.bpm.api.ExecutionContext in project concord by walmartlabs.
the class YamlParserTest method test033.
@SuppressWarnings("unchecked")
@Test
public void test033() throws Exception {
String txId = UUID.randomUUID().toString();
// ---
deploy("033.yml");
DockerTask task = spy(new DockerTask());
register("docker", task);
// ---
String key = UUID.randomUUID().toString();
Map<String, Object> args = new HashMap<>();
args.put("workDir", "/tmp");
args.put("txId", txId);
start(key, "main", args);
// ---
ArgumentCaptor<ExecutionContext> captor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(task, times(1)).execute(captor.capture());
ExecutionContext ctx = captor.getValue();
Map<String, Object> env = (Map<String, Object>) ctx.getVariable("env");
assertNotNull(env);
assertEquals(2, env.size());
assertEquals(123, env.get("x"));
assertEquals(txId, env.get("y"));
List<String> opts = (List<String>) ctx.getVariable("hosts");
assertNotNull(opts);
assertEquals(2, opts.size());
assertEquals("foo:10.0.0.3", opts.get(0));
}
use of io.takari.bpm.api.ExecutionContext in project concord by walmartlabs.
the class YamlParserTest method test063.
@Test
public void test063() throws Exception {
deploy("063.yml");
JavaDelegate checkpointTask = spy(new JavaDelegate() {
@Override
public void execute(ExecutionContext ctx) {
ctx.setVariable("checkpointId", "123");
}
});
register("checkpoint", checkpointTask);
// ---
String key = UUID.randomUUID().toString();
start(key, "main", null);
verify(checkpointTask, times(1)).execute(any());
verifyNoMoreInteractions(checkpointTask);
}
use of io.takari.bpm.api.ExecutionContext in project concord by walmartlabs.
the class YamlParserTest method test074.
@Test
public void test074() throws Exception {
deploy("074.yml");
register("__withItemsUtils", new StepConverter.WithItemsUtilsTask());
register("__retryUtils", new YamlTaskStepConverter.RetryUtilsTask());
MyLogger task = spy(new MyLogger());
register("log", task);
TestErrorTask http = spy(new TestErrorTask());
register("http", http);
// ---
String key = UUID.randomUUID().toString();
start(key, "default");
// ---
ArgumentCaptor<ExecutionContext> captor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(http, times(12)).execute(captor.capture());
List<String> urls = captor.getAllValues().stream().map(e -> (String) e.getVariable("url")).collect(Collectors.toList());
assertContains("https://nonexistant.example.com/test/a", urls, 4);
assertContains("https://nonexistant.example.com/test/b", urls, 4);
assertContains("https://nonexistant.example.com/test/c", urls, 4);
assertTrue(urls.isEmpty());
verifyNoMoreInteractions(http);
}
use of io.takari.bpm.api.ExecutionContext in project concord by walmartlabs.
the class YamlParserTest method test068.
@Test
public void test068() throws Exception {
deploy("068.yml");
MyLogger logBean = spy(new MyLogger());
register("log", logBean);
JavaDelegate task = mock(JavaDelegate.class);
doThrow(new BpmnError("first error")).doNothing().when(task).execute(any());
register("testErrorTask", task);
JavaDelegate task2 = mock(JavaDelegate.class);
doThrow(new BpmnError("first error")).doNothing().when(task2).execute(any());
register("testErrorTask2", task2);
register("__retryUtils", new YamlTaskStepConverter.RetryUtilsTask());
// ---
String key = UUID.randomUUID().toString();
start(key, "main", null);
// ---
ArgumentCaptor<ExecutionContext> ctxCaptor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(task, times(2)).execute(ctxCaptor.capture());
List<ExecutionContext> retryCtx = ctxCaptor.getAllValues();
assertEquals("test", retryCtx.get(0).getVariable("msg"));
assertEquals("retry", retryCtx.get(1).getVariable("msg"));
verifyNoMoreInteractions(task);
// ---
ArgumentCaptor<ExecutionContext> ctxCaptor2 = ArgumentCaptor.forClass(ExecutionContext.class);
verify(task2, times(2)).execute(ctxCaptor2.capture());
List<ExecutionContext> retryCtx2 = ctxCaptor2.getAllValues();
assertEquals("test2", retryCtx2.get(0).getVariable("msg"));
assertEquals("retry2", retryCtx2.get(1).getVariable("msg"));
verifyNoMoreInteractions(task2);
}
use of io.takari.bpm.api.ExecutionContext in project concord by walmartlabs.
the class YamlParserTest method test077.
@Test
public void test077() throws Exception {
deploy("077.yml");
ProcessDefinition pd = getDefinition("main");
TestBean testBean = spy(new TestBean());
register("testBean", testBean);
JavaDelegate task = mock(JavaDelegate.class);
doThrow(new BpmnError("first error")).doNothing().when(task).execute(any());
register("testErrorTask", task);
register("__retryUtils", new YamlTaskStepConverter.RetryUtilsTask());
// ---
String key = UUID.randomUUID().toString();
start(key, "main", null);
// ---
ArgumentCaptor<ExecutionContext> ctxCaptor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(task, times(2)).execute(ctxCaptor.capture());
List<ExecutionContext> retryCtx = ctxCaptor.getAllValues();
assertEquals("test", retryCtx.get(0).getVariable("msg"));
assertEquals("retry", retryCtx.get(1).getVariable("msg"));
verify(testBean, times(1)).toString(eq("end"));
verifyNoMoreInteractions(testBean);
verifyNoMoreInteractions(task);
}
Aggregations