@Test public void testDoSomething() { when(restService.getSomething()).thenReturn("abc"); mainService.doSomething(); verify(myPrinter).print("ABC"); }
public void doSomething() { if (restService == null) { System.out.println("restService not allowed to be null"); } String s = restService.getSomething(); System.out.println(s); if (printer == null) { System.out.println("printer not allowed to be null"); } printer.print(s.toUpperCase()); }
MainService { public void doSomething() { if (restService == null) { System.out.println("restService not allowed to be null"); } String s = restService.getSomething(); System.out.println(s); if (printer == null) { System.out.println("printer not allowed to be null"); } printer.print(s.toUpperCase()); } }
MainService { public void doSomething() { if (restService == null) { System.out.println("restService not allowed to be null"); } String s = restService.getSomething(); System.out.println(s); if (printer == null) { System.out.println("printer not allowed to be null"); } printer.print(s.toUpperCase()); } @Inject  MainService(RestService restService,  MyPrinter printer); }
MainService { public void doSomething() { if (restService == null) { System.out.println("restService not allowed to be null"); } String s = restService.getSomething(); System.out.println(s); if (printer == null) { System.out.println("printer not allowed to be null"); } printer.print(s.toUpperCase()); } @Inject  MainService(RestService restService,  MyPrinter printer); void doSomething(); }
MainService { public void doSomething() { if (restService == null) { System.out.println("restService not allowed to be null"); } String s = restService.getSomething(); System.out.println(s); if (printer == null) { System.out.println("printer not allowed to be null"); } printer.print(s.toUpperCase()); } @Inject  MainService(RestService restService,  MyPrinter printer); void doSomething();  }