use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTestingTest method testActivity.
@Test
public void testActivity() {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(ActivityWorkflow.class);
worker.registerActivitiesImplementations(new ActivityImpl());
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
TestWorkflow workflow = client.newWorkflowStub(TestWorkflow.class);
String result = workflow.workflow1("input1");
assertEquals("TestActivity::activity1-input1", result);
}
use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTestingTest method testFailure.
@Test
public void testFailure() {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(FailingWorkflowImpl.class);
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
TestWorkflow workflow = client.newWorkflowStub(TestWorkflow.class);
try {
workflow.workflow1("input1");
fail("unreacheable");
} catch (WorkflowException e) {
assertEquals("TestWorkflow::workflow1-input1", e.getCause().getMessage());
}
}
use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTestingTest method testActivityScheduleToStartTimeout.
@Test
public void testActivityScheduleToStartTimeout() {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
try {
workflow.workflow(10, 1, 10);
fail("unreacheable");
} catch (WorkflowException e) {
assertTrue(e.getCause() instanceof ActivityTimeoutException);
assertEquals(TimeoutType.SCHEDULE_TO_START, ((ActivityTimeoutException) e.getCause()).getTimeoutType());
}
}
use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTestingTest method testSignal.
@Test
public void testSignal() throws ExecutionException, InterruptedException {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(SignaledWorkflowImpl.class);
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
SignaledWorkflow workflow = client.newWorkflowStub(SignaledWorkflow.class);
CompletableFuture<String> result = WorkflowClient.execute(workflow::workflow1, "input1");
// after 1 hour sleep in the workflow
testEnvironment.sleep(Duration.ofMinutes(65));
workflow.ProcessSignal("signalInput");
assertEquals("signalInput-input1", result.get());
}
use of com.uber.cadence.client.WorkflowClient in project cadence-client by uber-java.
the class WorkflowTestingTest method testConcurrentDecision.
@Test
public void testConcurrentDecision() throws ExecutionException, InterruptedException {
Worker worker = testEnvironment.newWorker(TASK_LIST);
worker.registerWorkflowImplementationTypes(ConcurrentDecisionWorkflowImpl.class);
worker.start();
WorkflowClient client = testEnvironment.newWorkflowClient();
SignaledWorkflow workflow = client.newWorkflowStub(SignaledWorkflow.class);
CompletableFuture<String> result = WorkflowClient.execute(workflow::workflow1, "input1");
workflow.ProcessSignal("signalInput");
assertEquals("signalInput-input1", result.get());
System.out.println(testEnvironment.getDiagnostics());
}
Aggregations