Skip to content

Commit 97219e2

Browse files
authored
Added WorkflowTest.testWorkflowCancellationScopePromise (#127)
1 parent cee33b3 commit 97219e2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/test/java/com/uber/cadence/workflow/WorkflowTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,31 @@ public void testWorkflowCancellation() {
445445
}
446446
}
447447

448+
public static class TestCancellationScopePromise implements TestWorkflow1 {
449+
450+
@Override
451+
public String execute(String taskList) {
452+
Promise<String> cancellationRequest = CancellationScope.current().getCancellationRequest();
453+
cancellationRequest.get();
454+
return "done";
455+
}
456+
}
457+
458+
@Test
459+
public void testWorkflowCancellationScopePromise() {
460+
startWorkerFor(TestCancellationScopePromise.class);
461+
UntypedWorkflowStub client =
462+
workflowClient.newUntypedWorkflowStub(
463+
"TestWorkflow1::execute", newWorkflowOptionsBuilder(taskList).build());
464+
client.start(taskList);
465+
client.cancel();
466+
try {
467+
client.getResult(String.class);
468+
fail("unreachable");
469+
} catch (CancellationException ignored) {
470+
}
471+
}
472+
448473
public static class TestDetachedCancellationScope implements TestWorkflow1 {
449474

450475
@Override

0 commit comments

Comments
 (0)