Skip to content

Commit

Permalink
Make Java async accepted test more forgiving (#533)
Browse files Browse the repository at this point in the history
Make Java async accepted test more forgiving
  • Loading branch information
Quinn-With-Two-Ns authored Sep 5, 2024
1 parent 71c6d40 commit fb6ed5d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions features/update/async_accepted/feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,28 @@ public Run execute(Runner runner) throws Exception {
Assertions.assertEquals(UPDATE_RESULT, handle.getResultAsync().get());
// issue an async update that should throw
updateId = UUID.randomUUID().toString();
UpdateHandle<Integer> errorHandle =
untypedStub.startUpdate(
UpdateOptions.newBuilder(Integer.class)
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
false);
try {
// If the worker accepts the update, but fails it in the same workflow task
// the update will be marked as failed and the exception may be thrown
// from startUpdate. This is not consistent with the behavior of the
// other SDKs.
UpdateHandle<Integer> errorHandle =
untypedStub.startUpdate(
UpdateOptions.newBuilder(Integer.class)
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
false);
errorHandle.getResultAsync().get();
Assertions.fail("unreachable");
} catch (ExecutionException e) {
Assertions.assertTrue(e.getCause() instanceof WorkflowUpdateException);
WorkflowUpdateException wue = (WorkflowUpdateException) e.getCause();
} catch (Throwable e) {
if (e instanceof ExecutionException) {
e = e.getCause();
}
Assertions.assertTrue(e instanceof WorkflowUpdateException);
WorkflowUpdateException wue = (WorkflowUpdateException) e;
Assertions.assertTrue(wue.getCause() instanceof ApplicationFailure);
Assertions.assertEquals("Failure", ((ApplicationFailure) wue.getCause()).getType());
Assertions.assertEquals(
Expand Down

0 comments on commit fb6ed5d

Please sign in to comment.