Skip to content

Commit

Permalink
Run Java autoformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Jul 14, 2023
1 parent e8b12b9 commit 0635264
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 54 deletions.
8 changes: 4 additions & 4 deletions features/child_workflow/signal/ChildWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
@WorkflowInterface
public interface ChildWorkflow {

@WorkflowMethod
String childWorkflowExecute();
@WorkflowMethod
String childWorkflowExecute();

@SignalMethod
public void childWorkflowUnblock(String message);
@SignalMethod
public void childWorkflowUnblock(String message);
}
101 changes: 51 additions & 50 deletions features/child_workflow/signal/feature.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package child_workflow.signal;

import java.time.Duration;

import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.sdkfeatures.Assertions;
Expand All @@ -13,67 +11,70 @@
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import java.time.Duration;

@WorkflowInterface
public interface feature extends Feature {

@WorkflowMethod
public String workflow();

class Impl implements feature, ChildWorkflow {
private static final String UNBLOCK_MESSAGE = "unblock";
@WorkflowMethod
public String workflow();

/*
* Parent workflow
*
* A workflow that starts a child workflow, unblocks it, and returns the
* result of the child workflow.
*/
class Impl implements feature, ChildWorkflow {
private static final String UNBLOCK_MESSAGE = "unblock";

@Override
public String workflow() {
ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class);
Promise<String> childResult = Async.function(child::childWorkflowExecute);
child.childWorkflowUnblock(UNBLOCK_MESSAGE);
return childResult.get();
}
/*
* Parent workflow
*
* A workflow that starts a child workflow, unblocks it, and returns the
* result of the child workflow.
*/

/*
* Child workflow
*
* A workflow that waits for a signal and returns the data received.
*/
@Override
public String workflow() {
ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class);
Promise<String> childResult = Async.function(child::childWorkflowExecute);
child.childWorkflowUnblock(UNBLOCK_MESSAGE);
return childResult.get();
}

private String childWorkflowUnblockMessage = null;
/*
* Child workflow
*
* A workflow that waits for a signal and returns the data received.
*/

@Override
public String childWorkflowExecute() {
Workflow.await(() -> childWorkflowUnblockMessage != null);
return childWorkflowUnblockMessage;
}
private String childWorkflowUnblockMessage = null;

@Override
public void childWorkflowUnblock(String message) {
childWorkflowUnblockMessage = message;
}
@Override
public String childWorkflowExecute() {
Workflow.await(() -> childWorkflowUnblockMessage != null);
return childWorkflowUnblockMessage;
}

/* Test */
@Override
public void childWorkflowUnblock(String message) {
childWorkflowUnblockMessage = message;
}

@Override
public Run execute(Runner runner) throws Exception {
var options = WorkflowOptions.newBuilder().setTaskQueue(runner.config.taskQueue)
.setWorkflowExecutionTimeout(Duration.ofMinutes(1)).build();
var stub = runner.client.newWorkflowStub(feature.class, options);
var execution = WorkflowClient.start(stub::workflow);
var method = runner.featureInfo.metadata.getWorkflowMethods().get(0);
return new Run(method, execution);
}
/* Test */

@Override
public void checkResult(Runner runner, Run run) {
var resultStr = runner.waitForRunResult(run, String.class);
Assertions.assertEquals(UNBLOCK_MESSAGE, resultStr);
}
@Override
public Run execute(Runner runner) throws Exception {
var options =
WorkflowOptions.newBuilder()
.setTaskQueue(runner.config.taskQueue)
.setWorkflowExecutionTimeout(Duration.ofMinutes(1))
.build();
var stub = runner.client.newWorkflowStub(feature.class, options);
var execution = WorkflowClient.start(stub::workflow);
var method = runner.featureInfo.metadata.getWorkflowMethods().get(0);
return new Run(method, execution);
}

@Override
public void checkResult(Runner runner, Run run) {
var resultStr = runner.waitForRunResult(run, String.class);
Assertions.assertEquals(UNBLOCK_MESSAGE, resultStr);
}
}
}

0 comments on commit 0635264

Please sign in to comment.