@Test(expected = WebServerServiceException.class) public void testExecuteUnsupportedAction() { WebServer mockWebServer = mock(WebServer.class); when(mockWebServer.getName()).thenReturn("web-server-name"); when(mockWebServer.getHost()).thenReturn("web-server-host"); RemoteCommandReturnInfo startResult = webServerCommandFactory.executeCommand(mockWebServer, WebServerControlOperation.BACK_UP); assertEquals(0, startResult.retCode); }
public RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).apply(webserver); } throw new WebServerServiceException("WebServerCommand not found: " + operation.getExternalValue()); }
WebServerCommandFactory { public RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).apply(webserver); } throw new WebServerServiceException("WebServerCommand not found: " + operation.getExternalValue()); } }
WebServerCommandFactory { public RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).apply(webserver); } throw new WebServerServiceException("WebServerCommand not found: " + operation.getExternalValue()); }  }
WebServerCommandFactory { public RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).apply(webserver); } throw new WebServerServiceException("WebServerCommand not found: " + operation.getExternalValue()); }  RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation); @PostConstruct void initWebServerCommands(); }
WebServerCommandFactory { public RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).apply(webserver); } throw new WebServerServiceException("WebServerCommand not found: " + operation.getExternalValue()); }  RemoteCommandReturnInfo executeCommand(WebServer webserver, WebServerControlOperation operation); @PostConstruct void initWebServerCommands();  }