use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTest method testChildWorkflowRetry.
@Test
public void testChildWorkflowRetry() {
AngryChildActivityImpl angryChildActivity = new AngryChildActivityImpl();
worker.registerActivitiesImplementations(angryChildActivity);
startWorkerFor(TestChildWorkflowRetryWorkflow.class, AngryChild.class);
WorkflowOptions.Builder options = new WorkflowOptions.Builder();
options.setExecutionStartToCloseTimeout(Duration.ofSeconds(20));
options.setTaskStartToCloseTimeout(Duration.ofSeconds(2));
options.setTaskList(taskList);
AtomicReference<String> capturedWorkflowType = new AtomicReference<>();
WorkflowClientOptions clientOptions = new WorkflowClientOptions.Builder().setInterceptors(new WorkflowClientInterceptorBase() {
@Override
public WorkflowStub newUntypedWorkflowStub(String workflowType, WorkflowOptions options, WorkflowStub next) {
capturedWorkflowType.set(workflowType);
return next;
}
}).build();
WorkflowClient wc;
if (useExternalService) {
wc = WorkflowClient.newInstance(domain, clientOptions);
} else {
wc = testEnvironment.newWorkflowClient(clientOptions);
}
TestWorkflow1 client = wc.newWorkflowStub(TestWorkflow1.class, options.build());
try {
client.execute(taskList);
fail("unreachable");
} catch (WorkflowException e) {
assertTrue(e.getCause() instanceof ChildWorkflowFailureException);
assertTrue(e.getCause().getCause() instanceof UnsupportedOperationException);
assertEquals("simulated failure", e.getCause().getCause().getMessage());
}
assertEquals("TestWorkflow1::execute", capturedWorkflowType.get());
assertEquals(3, angryChildActivity.getInvocationCount());
}
Aggregations