use of com.uber.cadence.client.WorkflowClientOptions in project cadence-client by uber-java.
the class WorkflowTest method setUp.
@Before
public void setUp() {
if (testName.getMethodName().equals("testExecute[TestService]") || testName.getMethodName().equals("testStart[TestService]")) {
taskList = ANNOTATION_TASK_LIST;
} else {
taskList = "WorkflowTest-" + testName.getMethodName();
}
if (useExternalService) {
worker = new Worker(domain, taskList);
workflowClient = WorkflowClient.newInstance(domain);
WorkflowClientOptions clientOptions = new WorkflowClientOptions.Builder().setDataConverter(JsonDataConverter.getInstance()).build();
workflowClientWithOptions = WorkflowClient.newInstance(domain, clientOptions);
scheduledExecutor = new ScheduledThreadPoolExecutor(1);
} else {
TestEnvironmentOptions testOptions = new Builder().setDomain(domain).build();
testEnvironment = TestWorkflowEnvironment.newInstance(testOptions);
worker = testEnvironment.newWorker(taskList);
workflowClient = testEnvironment.newWorkflowClient();
workflowClientWithOptions = testEnvironment.newWorkflowClient();
}
ActivityCompletionClient completionClient = workflowClient.newActivityCompletionClient();
activitiesImpl = new TestActivitiesImpl(completionClient);
worker.registerActivitiesImplementations(activitiesImpl);
newWorkflowOptionsBuilder(taskList);
newActivityOptions1(taskList);
activitiesImpl.invocations.clear();
activitiesImpl.procResult.clear();
}
use of com.uber.cadence.client.WorkflowClientOptions 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