@@ -1662,7 +1662,7 @@ public String execute(String taskList) {
1662
1662
1663
1663
WaitOnSignalWorkflow child =
1664
1664
Workflow .newChildWorkflowStub (WaitOnSignalWorkflow .class , workflowOptions );
1665
- Promise <Void > promise = Async .procedure (() -> child . execute () );
1665
+ Promise <Void > promise = Async .procedure (child :: execute );
1666
1666
Promise <WorkflowExecution > executionPromise = Workflow .getWorkflowExecution (child );
1667
1667
assertNotNull (executionPromise );
1668
1668
WorkflowExecution execution = executionPromise .get ();
@@ -2854,6 +2854,48 @@ public void testChildWorkflowRetryReplay() throws Exception {
2854
2854
"testChildWorkflowRetryHistory.json" , TestChildWorkflowRetryWorkflow .class );
2855
2855
}
2856
2856
2857
+ public static class TestChildWorkflowExecutionPromiseHandler implements TestWorkflow1 {
2858
+
2859
+ private ITestNamedChild child ;
2860
+
2861
+ @ Override
2862
+ public String execute (String taskList ) {
2863
+ child = Workflow .newChildWorkflowStub (ITestNamedChild .class );
2864
+ Promise <String > childResult = Async .function (child ::execute , "foo" );
2865
+ Promise <WorkflowExecution > executionPromise = Workflow .getWorkflowExecution (child );
2866
+ CompletablePromise <String > result = Workflow .newPromise ();
2867
+ // Ensure that the callback can execute Workflow.* functions.
2868
+ executionPromise .thenApply (
2869
+ (we ) -> {
2870
+ Workflow .sleep (Duration .ofSeconds (1 ));
2871
+ result .complete (childResult .get ());
2872
+ return null ;
2873
+ });
2874
+ return result .get ();
2875
+ }
2876
+ }
2877
+
2878
+ /** Tests that handler of the WorkflowExecution promise is executed in a workflow thread. */
2879
+ @ Test
2880
+ public void testChildWorkflowExecutionPromiseHandler () {
2881
+ startWorkerFor (TestChildWorkflowExecutionPromiseHandler .class , TestNamedChild .class );
2882
+
2883
+ WorkflowOptions .Builder options = new WorkflowOptions .Builder ();
2884
+ options .setExecutionStartToCloseTimeout (Duration .ofSeconds (20 ));
2885
+ options .setTaskStartToCloseTimeout (Duration .ofSeconds (2 ));
2886
+ options .setTaskList (taskList );
2887
+ WorkflowClient wc ;
2888
+ if (useExternalService ) {
2889
+ wc = WorkflowClient .newInstance (service , DOMAIN );
2890
+ } else {
2891
+ wc = testEnvironment .newWorkflowClient ();
2892
+ }
2893
+
2894
+ TestWorkflow1 client = wc .newWorkflowStub (TestWorkflow1 .class , options .build ());
2895
+ String result = client .execute (taskList );
2896
+ assertEquals ("FOO" , result );
2897
+ }
2898
+
2857
2899
public static class TestSignalExternalWorkflow implements TestWorkflowSignaled {
2858
2900
2859
2901
private final SignalingChild child = Workflow .newChildWorkflowStub (SignalingChild .class );
0 commit comments