use of com.uber.cadence.workflow.ActivityTimeoutException 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());
}
}
use of com.uber.cadence.workflow.ActivityTimeoutException 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.workflow.ActivityTimeoutException 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());
}
}
use of com.uber.cadence.workflow.ActivityTimeoutException in project cadence-client by uber-java.
the class SyncDecisionContext method mapActivityException.
private RuntimeException mapActivityException(Exception failure) {
if (failure == null) {
return null;
}
if (failure instanceof CancellationException) {
return (CancellationException) failure;
}
if (failure instanceof ActivityTaskFailedException) {
ActivityTaskFailedException taskFailed = (ActivityTaskFailedException) failure;
String causeClassName = taskFailed.getReason();
Class<? extends Exception> causeClass;
Exception cause;
try {
// cc is just to have a place to put this annotation
@SuppressWarnings("unchecked") Class<? extends Exception> cc = (Class<? extends Exception>) Class.forName(causeClassName);
causeClass = cc;
cause = getDataConverter().fromData(taskFailed.getDetails(), causeClass);
} catch (Exception e) {
cause = e;
}
return new ActivityFailureException(taskFailed.getEventId(), taskFailed.getActivityType(), taskFailed.getActivityId(), cause);
}
if (failure instanceof ActivityTaskTimeoutException) {
ActivityTaskTimeoutException timedOut = (ActivityTaskTimeoutException) failure;
return new ActivityTimeoutException(timedOut.getEventId(), timedOut.getActivityType(), timedOut.getActivityId(), timedOut.getTimeoutType(), timedOut.getDetails(), getDataConverter());
}
if (failure instanceof ActivityException) {
return (ActivityException) failure;
}
throw new IllegalArgumentException("Unexpected exception type: " + failure.getClass().getName(), failure);
}
Aggregations