use of io.takari.bpm.api.JavaDelegate 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.JavaDelegate 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.JavaDelegate 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);
}
use of io.takari.bpm.api.JavaDelegate in project concord by walmartlabs.
the class YamlParserTest method test058.
@Test
public void test058() throws Exception {
deploy("058.yml");
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());
register("__withItemsUtils", new StepConverter.WithItemsUtilsTask());
// ---
String key = UUID.randomUUID().toString();
start(key, "main", null);
// ---
ArgumentCaptor<ExecutionContext> ctxCaptor = ArgumentCaptor.forClass(ExecutionContext.class);
verify(task, times(3)).execute(ctxCaptor.capture());
List<ExecutionContext> retryCtx = ctxCaptor.getAllValues();
assertEquals("test: item1", retryCtx.get(0).getVariable("msg"));
assertEquals("retry: item1", retryCtx.get(1).getVariable("msg"));
assertEquals("test: item2", retryCtx.get(2).getVariable("msg"));
verify(testBean, times(1)).toString(eq("end"));
verifyNoMoreInteractions(testBean);
verifyNoMoreInteractions(task);
}
use of io.takari.bpm.api.JavaDelegate in project concord by walmartlabs.
the class YamlParserTest method test035.
@Test
public void test035() throws Exception {
deploy("035.yml");
JavaDelegate task = spy(new JavaDelegate() {
@SuppressWarnings("rawtypes")
@Override
public void execute(ExecutionContext ctx) {
Object o = ctx.getVariable("aList");
assertTrue(o instanceof List);
List l = (List) o;
assertEquals(3, l.size());
assertEquals(132, l.get(2));
}
});
register("testTask", task);
// ---
String key = UUID.randomUUID().toString();
start(key, "main", null);
// ---
verify(task, times(1)).execute(any(ExecutionContext.class));
}
Aggregations