@Test public void testExecuteViewHttpdConf() throws IOException { WebServer mockWebServer = mock(WebServer.class); when(mockWebServer.getName()).thenReturn("web-server-name"); when(mockWebServer.getHost()).thenReturn("web-server-host"); when(Config.mockRemoteCommandExecutorService.executeCommand(any(RemoteExecCommand.class))).thenReturn(new RemoteCommandReturnInfo(0, "View HTTPD conf command succeeded", "")); ResourceContent mockResourceContent = mock(ResourceContent.class); when(mockResourceContent.getMetaData()).thenReturn("{deployPath:\"/fake/deploy/path\"}"); ResourceTemplateMetaData mockResourceTemplateMetaData = mock(ResourceTemplateMetaData.class); when(mockResourceTemplateMetaData.getDeployPath()).thenReturn("/fake/deploy/path"); when(Config.mockResourceService.getResourceContent(any(ResourceIdentifier.class))).thenReturn(mockResourceContent); when(Config.mockResourceService.getMetaData(anyString())).thenReturn(mockResourceTemplateMetaData); when(Config.mockResourceContentGeneratorService.generateContent(anyString(), anyString(), any(ResourceGroup.class), anyObject(), any(ResourceGeneratorType.class))).thenReturn("/fake/deploy/path"); RemoteCommandReturnInfo startResult = webServerCommandFactory.executeCommand(mockWebServer, WebServerControlOperation.VIEW_HTTP_CONFIG_FILE); 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();  }