use of io.takari.bpm.api.BpmnError 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.BpmnError 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.BpmnError in project concord by walmartlabs.
the class ProcessErrorProcessor method getError.
private static Throwable getError(Throwable t) {
t = unroll(t);
if (t instanceof BpmnError) {
BpmnError error = (BpmnError) t;
if (!DEFAULT_ERROR_REF.equals(error.getErrorRef())) {
return error;
}
Throwable cause = error.getCause();
if (cause == null) {
return error;
}
}
if (t instanceof ELException && t.getCause() != null) {
return t.getCause();
}
return t;
}
use of io.takari.bpm.api.BpmnError 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.BpmnError in project concord by walmartlabs.
the class YamlParserTest method test048.
@Test
public void test048() throws Exception {
deploy("048.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());
// ---
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"));
Map<String, String> expectedVars0 = new HashMap<>();
expectedVars0.put("a", "a-value-original");
expectedVars0.put("b", "b-value-original");
Map<String, String> expectedVars1 = new HashMap<>();
expectedVars1.put("a", "a-value-original");
expectedVars1.put("b", "b-value-retry");
assertEquals(expectedVars0, retryCtx.get(0).getVariable("nested"));
assertEquals(expectedVars1, retryCtx.get(1).getVariable("nested"));
verify(testBean, times(1)).toString(eq("end"));
verifyNoMoreInteractions(testBean);
verifyNoMoreInteractions(task);
}
Aggregations