Search in sources :

Example 6 with Worker

use of com.uber.cadence.worker.Worker in project cadence-client by uber-java.

the class WorkflowTestingTest method testEmptyWorkflow.

@Test
public void testEmptyWorkflow() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(EmptyWorkflowImpl.class);
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestWorkflow workflow = client.newWorkflowStub(TestWorkflow.class);
    String result = workflow.workflow1("input1");
    assertEquals("TestWorkflow::workflow1-input1", result);
}
Also used : Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 7 with Worker

use of com.uber.cadence.worker.Worker in project cadence-client by uber-java.

the class WorkflowTestingTest method testChild.

@Test
public void testChild() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(ChildWorklfowImpl.class, ParentWorkflowImpl.class);
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    WorkflowOptions options = new WorkflowOptions.Builder().setWorkflowId("parent1").build();
    ParentWorkflow workflow = client.newWorkflowStub(ParentWorkflow.class, options);
    String result = workflow.workflow("input1");
    assertEquals("child input1", result);
}
Also used : Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) WorkflowOptions(com.uber.cadence.client.WorkflowOptions) Test(org.junit.Test)

Example 8 with Worker

use of com.uber.cadence.worker.Worker 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);
}
Also used : Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 9 with Worker

use of com.uber.cadence.worker.Worker 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());
    }
}
Also used : WorkflowException(com.uber.cadence.client.WorkflowException) Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Example 10 with Worker

use of com.uber.cadence.worker.Worker 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());
    }
}
Also used : ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) WorkflowException(com.uber.cadence.client.WorkflowException) Worker(com.uber.cadence.worker.Worker) WorkflowClient(com.uber.cadence.client.WorkflowClient) Test(org.junit.Test)

Aggregations

Worker (com.uber.cadence.worker.Worker)18 Test (org.junit.Test)16 WorkflowClient (com.uber.cadence.client.WorkflowClient)15 WorkflowException (com.uber.cadence.client.WorkflowException)7 WorkflowExecution (com.uber.cadence.WorkflowExecution)3 WorkflowOptions (com.uber.cadence.client.WorkflowOptions)3 ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)3 CancellationException (java.util.concurrent.CancellationException)3 WorkflowStub (com.uber.cadence.client.WorkflowStub)2 GetWorkflowExecutionHistoryRequest (com.uber.cadence.GetWorkflowExecutionHistoryRequest)1 History (com.uber.cadence.History)1 HistoryEvent (com.uber.cadence.HistoryEvent)1 ActivityCancelledException (com.uber.cadence.client.ActivityCancelledException)1 ActivityCompletionClient (com.uber.cadence.client.ActivityCompletionClient)1 ActivityNotExistsException (com.uber.cadence.client.ActivityNotExistsException)1 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)1 WorkflowClientOptions (com.uber.cadence.client.WorkflowClientOptions)1 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)1 WorkflowTimedOutException (com.uber.cadence.client.WorkflowTimedOutException)1 DeterministicRunnerTest (com.uber.cadence.internal.sync.DeterministicRunnerTest)1