WakeOnLanHostService { public String startHost(String mac) { return shellCommandUtils.executeCommand(String.format("%s %s", wakeOnLanCommand, mac)); }  String startHost(String mac);  }
@Test public void startHostTest() throws Exception { String mac = "4f:2e:34:d9:fe:76"; String commandToBeExecuted = String.format("%s %s", "/usr/bin/wakeonlan", mac); ShellCommandUtils shellCommandUtils = Mockito.mock(ShellCommandUtils.class); Mockito.when(shellCommandUtils.executeCommand(commandToBeExecuted)).thenReturn("test"); WakeOnLanHostService service = new WakeOnLanHostService(); service.shellCommandUtils = shellCommandUtils; String commandReturn = service.startHost(mac); Assert.assertEquals("test", commandReturn); Mockito.verify(shellCommandUtils).executeCommand(commandToBeExecuted); }