Skip to content

Commit

Permalink
Point sample at released SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Oct 15, 2024
1 parent fd3139c commit 6de76d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ subprojects {
ext {
otelVersion = '1.30.1'
otelVersionAlpha = "${otelVersion}-alpha"
javaSDKVersion = '1.23.0-SNAPSHOT'
javaSDKVersion = '1.26.0'
camelVersion = '3.22.1'
jarVersion = '1.0.0'
nexusVersion = '0.1.0-alpha1'
}

repositories {
mavenLocal()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@
package io.temporal.samples.nexus.caller;

import io.temporal.samples.nexus.service.NexusService;
import io.temporal.workflow.NexusOperationOptions;
import io.temporal.workflow.NexusServiceOptions;
import io.temporal.workflow.Workflow;
import java.time.Duration;

public class EchoCallerWorkflowImpl implements EchoCallerWorkflow {
NexusService nexusService = Workflow.newNexusServiceStub(NexusService.class);
NexusService nexusService =
Workflow.newNexusServiceStub(
NexusService.class,
NexusServiceOptions.newBuilder()
.setOperationOptions(
NexusOperationOptions.newBuilder()
.setScheduleToCloseTimeout(Duration.ofSeconds(10))
.build())
.build());

@Override
public String echo(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.junit.Rule;
import org.junit.Test;

import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand All @@ -44,13 +46,16 @@ public class CallerWorkflowTest {
// of the TestWorkflowRule will automatically inherit the endpoint if none is set.
.setNexusServiceImplementation(new NexusServiceImpl())
.setWorkflowTypes(HelloCallerWorkflowImpl.class)
// Disable automatic worker startup as we are going to register some workflows manually
// per test
.setDoNotStart(true)
.build();

@Test
public void testHelloWorkflow() {
testWorkflowRule
.getWorker()
// Workflows started by a Nexus service can be mocked just like any other workflow
.registerWorkflowImplementationFactory(
HelloHandlerWorkflow.class,
() -> {
Expand All @@ -74,14 +79,19 @@ public void testHelloWorkflow() {

@Test
public void testEchoWorkflow() {
// If Workflows are registered later than the endpoint can be set manually
// either by setting the endpoint in the NexusServiceOptions in the Workflow implementation or by setting the
// NexusServiceOptions on the WorkflowImplementationOptions when registering the Workflow.
testWorkflowRule
.getWorker()
.registerWorkflowImplementationTypes(
WorkflowImplementationOptions.newBuilder()
.setDefaultNexusServiceOptions(
NexusServiceOptions.newBuilder()
.setEndpoint(testWorkflowRule.getNexusEndpoint().getSpec().getName())
.build())
.setNexusServiceOptions(
Collections.singletonMap(
"NexusService",
NexusServiceOptions.newBuilder()
.setEndpoint(testWorkflowRule.getNexusEndpoint().getSpec().getName())
.build()))
.build(),
EchoCallerWorkflowImpl.class);
testWorkflowRule.getTestEnvironment().start();
Expand Down

0 comments on commit 6de76d0

Please sign in to comment.