Skip to content

Commit d6f0a08

Browse files
authored
Adding snips for documentation pages (#772)
1 parent 385adc4 commit d6f0a08

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowJunit5MockTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// This is an example of how to unit test Nexus services in JUnit5. The handlers are mocked,
1717
// so that the caller classes interact with the mocks and not the handler classes themselves.
1818

19+
// @@@SNIPSTART java-nexus-sample-junit5-mock
1920
public class CallerWorkflowJunit5MockTest {
2021

2122
// Sync Nexus operations run inline in the handler thread — there is no backing workflow to
@@ -77,3 +78,5 @@ public void testEchoWorkflow(
7778
testEnv.shutdown();
7879
}
7980
}
81+
82+
// @@@SNIPEND

core/src/test/java/io/temporal/samples/nexus/caller/CallerWorkflowMockTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// This is an example of how to unit test Nexus services in JUnit4. The handlers are mocked,
1818
// so that the caller classes interact with the mocks and not the handler classes themselves.
1919

20+
// @@@SNIPSTART java-nexus-sample-junit4-mock
2021
public class CallerWorkflowMockTest {
2122

2223
// Inject a mock EchoClient so sync Nexus operations can be stubbed per test.
@@ -90,3 +91,5 @@ public void testEchoWorkflow() {
9091
testWorkflowRule.getTestEnvironment().shutdown();
9192
}
9293
}
94+
95+
// @@@SNIPEND

core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceJunit5Test.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// This is the path to take when you don't have access to the service implementation so
1919
// cannot mock it. Since the SampleNexusService itself is mocked,
2020
// no handlers need to be set up or mocked.
21+
22+
// @@@SNIPSTART java-nexus-service-sample-junit4-mock
2123
public class NexusServiceJunit5Test {
2224

2325
private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
@@ -103,3 +105,5 @@ public void testEchoWorkflow(
103105
verifyNoMoreInteractions(mockNexusService);
104106
}
105107
}
108+
109+
// @@@SNIPEND

core/src/test/java/io/temporal/samples/nexus/caller/NexusServiceMockTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// This is the path to take when you don't have access to the service implementation so
1818
// cannot mock it. Since the SampleNexusService itself is mocked,
1919
// no handlers need to be set up or mocked.
20+
21+
// @@@SNIPSTART java-nexus-service-sample-junit4-mock
2022
public class NexusServiceMockTest {
2123

2224
private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
@@ -102,3 +104,5 @@ public void testEchoCallerWithMockedService() {
102104
verifyNoMoreInteractions(mockNexusService);
103105
}
104106
}
107+
108+
// @@@SNIPEND

0 commit comments

Comments
 (0)