Search in sources :

Example 1 with WorkflowException

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

the class WorkflowTestingTest method testActivityScheduleToCloseTimeout.

@Test
public void testActivityScheduleToCloseTimeout() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
    worker.registerActivitiesImplementations(new TimingOutActivityImpl());
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
    try {
        workflow.workflow(1, 10, 10);
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertTrue(e.getCause() instanceof ActivityTimeoutException);
        assertEquals(TimeoutType.SCHEDULE_TO_CLOSE, ((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)

Example 2 with WorkflowException

use of com.uber.cadence.client.WorkflowException 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 3 with WorkflowException

use of com.uber.cadence.client.WorkflowException 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)

Example 4 with WorkflowException

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

the class WorkflowTestingTest method testActivityStartToCloseTimeout.

@Test
public void testActivityStartToCloseTimeout() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(TestActivityTimeoutWorkflowImpl.class);
    worker.registerActivitiesImplementations(new TimingOutActivityImpl());
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestActivityTimeoutWorkflow workflow = client.newWorkflowStub(TestActivityTimeoutWorkflow.class);
    try {
        workflow.workflow(10, 10, 1);
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertTrue(e.getCause() instanceof ActivityTimeoutException);
        assertEquals(TimeoutType.START_TO_CLOSE, ((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)

Example 5 with WorkflowException

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

the class WorkflowTestingTest method testActivityFailure.

@Test
public void testActivityFailure() {
    Worker worker = testEnvironment.newWorker(TASK_LIST);
    worker.registerWorkflowImplementationTypes(ActivityWorkflow.class);
    worker.registerActivitiesImplementations(new FailingActivityImpl());
    worker.start();
    WorkflowClient client = testEnvironment.newWorkflowClient();
    TestWorkflow workflow = client.newWorkflowStub(TestWorkflow.class);
    try {
        workflow.workflow1("input1");
        fail("unreacheable");
    } catch (WorkflowException e) {
        assertEquals("TestActivity::activity1-input1", e.getCause().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)

Aggregations

WorkflowException (com.uber.cadence.client.WorkflowException)8 WorkflowClient (com.uber.cadence.client.WorkflowClient)7 Test (org.junit.Test)7 Worker (com.uber.cadence.worker.Worker)6 ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)3 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)2 WorkflowOptions (com.uber.cadence.client.WorkflowOptions)2 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 WorkflowClientInterceptorBase (com.uber.cadence.client.WorkflowClientInterceptorBase)1 WorkflowClientOptions (com.uber.cadence.client.WorkflowClientOptions)1 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)1 WorkflowNotFoundException (com.uber.cadence.client.WorkflowNotFoundException)1 WorkflowQueryException (com.uber.cadence.client.WorkflowQueryException)1 WorkflowServiceException (com.uber.cadence.client.WorkflowServiceException)1 WorkflowStub (com.uber.cadence.client.WorkflowStub)1 WorkflowTimedOutException (com.uber.cadence.client.WorkflowTimedOutException)1 WorkflowExecutionFailedException (com.uber.cadence.internal.common.WorkflowExecutionFailedException)1 DeterministicRunnerTest (com.uber.cadence.internal.sync.DeterministicRunnerTest)1 Builder (com.uber.cadence.testing.TestEnvironmentOptions.Builder)1 CancellationException (java.util.concurrent.CancellationException)1