11package io .temporal .samples .nexus .caller ;
22
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .mockito .Mockito .*;
5+
36import io .temporal .samples .nexus .handler .EchoHandler ;
47import io .temporal .samples .nexus .handler .HelloHandlerWorkflow ;
58import io .temporal .samples .nexus .handler .NexusServiceImpl ;
1013import org .junit .jupiter .api .Test ;
1114import org .junit .jupiter .api .extension .RegisterExtension ;
1215
13- import static org .junit .jupiter .api .Assertions .assertEquals ;
14- import static org .mockito .Mockito .*;
15-
1616public class CallerWorkflowJunit5MockTest {
1717
1818 // Sync Nexus operations run inline in the handler thread — there is no backing workflow to
@@ -23,23 +23,24 @@ public class CallerWorkflowJunit5MockTest {
2323 public static final TestWorkflowExtension testWorkflowExtension =
2424 TestWorkflowExtension .newBuilder ()
2525 // If a Nexus service is registered as part of the test as in the following line of code,
26- // the TestWorkflowExtension will, by default, automatically create a Nexus service endpoint
27- // and workflows registered as part of the TestWorkflowExtension will
26+ // the TestWorkflowExtension will, by default, automatically create a Nexus service
27+ // endpoint and workflows registered as part of the TestWorkflowExtension will
2828 // automatically inherit the endpoint if none is set.
2929 .setNexusServiceImplementation (new NexusServiceImpl (mockEchoHandler ))
3030 // The Echo Nexus handler service just makes a call to a class, so no extra setup is
3131 // needed. But the Hello Nexus service needs a worker for both the caller and handler
3232 // in order to run, and the Echo Nexus caller service needs a worker.
3333 //
34- // registerWorkflowImplementationTypes will take the classes given and create workers for them,
35- // enabling workflows to run.
34+ // registerWorkflowImplementationTypes will take the classes given and create workers for
35+ // them, enabling workflows to run.
3636 .registerWorkflowImplementationTypes (
3737 HelloCallerWorkflowImpl .class , EchoCallerWorkflowImpl .class )
3838 .setDoNotStart (true )
3939 .build ();
4040
4141 @ Test
42- public void testHelloWorkflow (TestWorkflowEnvironment testEnv , Worker worker , HelloCallerWorkflow workflow ) {
42+ public void testHelloWorkflow (
43+ TestWorkflowEnvironment testEnv , Worker worker , HelloCallerWorkflow workflow ) {
4344 // Workflows started by a Nexus service can be mocked just like any other workflow
4445 worker .registerWorkflowImplementationFactory (
4546 HelloHandlerWorkflow .class ,
@@ -59,7 +60,8 @@ public void testHelloWorkflow(TestWorkflowEnvironment testEnv, Worker worker, He
5960 }
6061
6162 @ Test
62- public void testEchoWorkflow (TestWorkflowEnvironment testEnv , Worker worker , EchoCallerWorkflow workflow ) {
63+ public void testEchoWorkflow (
64+ TestWorkflowEnvironment testEnv , Worker worker , EchoCallerWorkflow workflow ) {
6365 // Sync Nexus operations run inline in the handler thread — there is no backing workflow to
6466 // register a factory for. Instead, stub the injected EchoHandler dependency directly.
6567 when (mockEchoHandler .echo (any ())).thenReturn (new NexusService .EchoOutput ("mocked echo" ));
0 commit comments