Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// This is an example of how to unit test Nexus services in JUnit5. The handlers are mocked,
// so that the caller classes interact with the mocks and not the handler classes themselves.

// @@@SNIPSTART java-nexus-sample-junit5-mock
public class CallerWorkflowJunit5MockTest {

// Sync Nexus operations run inline in the handler thread — there is no backing workflow to
Expand Down Expand Up @@ -77,3 +78,5 @@ public void testEchoWorkflow(
testEnv.shutdown();
}
}

// @@@SNIPEND
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// This is an example of how to unit test Nexus services in JUnit4. The handlers are mocked,
// so that the caller classes interact with the mocks and not the handler classes themselves.

// @@@SNIPSTART java-nexus-sample-junit4-mock
public class CallerWorkflowMockTest {

// Inject a mock EchoClient so sync Nexus operations can be stubbed per test.
Expand Down Expand Up @@ -90,3 +91,5 @@ public void testEchoWorkflow() {
testWorkflowRule.getTestEnvironment().shutdown();
}
}

// @@@SNIPEND
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// This is the path to take when you don't have access to the service implementation so
// cannot mock it. Since the SampleNexusService itself is mocked,
// no handlers need to be set up or mocked.

// @@@SNIPSTART java-nexus-service-sample-junit4-mock
public class NexusServiceJunit5Test {

private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
Expand Down Expand Up @@ -103,3 +105,5 @@ public void testEchoWorkflow(
verifyNoMoreInteractions(mockNexusService);
}
}

// @@@SNIPEND
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// This is the path to take when you don't have access to the service implementation so
// cannot mock it. Since the SampleNexusService itself is mocked,
// no handlers need to be set up or mocked.

// @@@SNIPSTART java-nexus-service-sample-junit4-mock
public class NexusServiceMockTest {

private final SampleNexusService mockNexusService = mock(SampleNexusService.class);
Expand Down Expand Up @@ -102,3 +104,5 @@ public void testEchoCallerWithMockedService() {
verifyNoMoreInteractions(mockNexusService);
}
}

// @@@SNIPEND
Loading