@Test public void testGenerateAndDeployConfig() throws CommandFailureException, IOException { when(Config.mockWebServerService.getResourceTemplateMetaData(anyString(), anyString())).thenReturn("{\"contentType\":\"text/plain\",\"deployPath\":\"./anyPath\",\"deployFileName\":\"httpd.conf\"}"); CommandOutput commandOutput = mock(CommandOutput.class); ExecReturnCode execReturnCode = mock(ExecReturnCode.class); when(commandOutput.getReturnCode()).thenReturn(execReturnCode); when(commandOutput.getReturnCode().wasSuccessful()).thenReturn(true); when(Config.mockResourceService.generateResourceGroup()).thenReturn(new ResourceGroup()); when(Config.mockResourceService.generateResourceFile(anyString(), anyString(), any(ResourceGroup.class), any(), any(ResourceGeneratorType.class))).thenReturn("{\"contentType\":\"text/plain\",\"deployPath\":\"./anyPath\",\"deployFileName\":\"httpd.conf\"}"); ResourceTemplateMetaData mockMetaData = mock(ResourceTemplateMetaData.class); when(mockMetaData.getDeployFileName()).thenReturn("httpd.conf"); when(mockMetaData.getDeployPath()).thenReturn("./anyPath"); when(mockMetaData.getContentType()).thenReturn(MediaType.TEXT_PLAIN); when(Config.mockResourceService.getTokenizedMetaData(anyString(), Matchers.anyObject(), anyString())).thenReturn(mockMetaData); Response response = webServerServiceRest.generateAndDeployConfig(webServer.getName(), "httpd.conf", Config.mockAuthenticatedUser); assertTrue(response.hasEntity()); }
@Override public Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user) { LOGGER.info("Generate and deploy config {} for web server {} by user {}", resourceFileName, aWebServerName, user.getUser().getId()); return ResponseBuilder.ok(webServerService.generateAndDeployFile(aWebServerName, resourceFileName, user.getUser())); }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user) { LOGGER.info("Generate and deploy config {} for web server {} by user {}", resourceFileName, aWebServerName, user.getUser().getId()); return ResponseBuilder.ok(webServerService.generateAndDeployFile(aWebServerName, resourceFileName, user.getUser())); } }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user) { LOGGER.info("Generate and deploy config {} for web server {} by user {}", resourceFileName, aWebServerName, user.getUser().getId()); return ResponseBuilder.ok(webServerService.generateAndDeployFile(aWebServerName, resourceFileName, user.getUser())); } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user) { LOGGER.info("Generate and deploy config {} for web server {} by user {}", resourceFileName, aWebServerName, user.getUser().getId()); return ResponseBuilder.ok(webServerService.generateAndDeployFile(aWebServerName, resourceFileName, user.getUser())); } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); @Override Response getWebServers(final Identifier<Group> aGroupId); @Override Response getWebServer(final Identifier<WebServer> aWsId); @Override Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response updateWebServer(final JsonUpdateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response deleteWebServer(final Identifier<WebServer> id, boolean hardDelete, final AuthenticatedUser authUser); @Override Response controlWebServer(final Identifier<WebServer> aWebServerId,
                                     final JsonControlWebServer aWebServerToControl, final AuthenticatedUser aUser,
                                     final Boolean wait, Long waitTimeout); @Override Response generateConfig(final String webServerName); @Override Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user); @Override Response generateAndDeployWebServer(final String aWebServerName, final AuthenticatedUser aUser); @Override Response getHttpdConfig(Identifier<WebServer> aWebServerId); @Override Response getResourceNames(final String wsName); @Override Response getResourceTemplate(final String wsName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String wsName, final String resourceTemplateName, final String content); @Override Response previewResourceTemplate(final String webServerName, final String fileName, final String groupName, String template); }
WebServerServiceRestImpl implements WebServerServiceRest { @Override public Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user) { LOGGER.info("Generate and deploy config {} for web server {} by user {}", resourceFileName, aWebServerName, user.getUser().getId()); return ResponseBuilder.ok(webServerService.generateAndDeployFile(aWebServerName, resourceFileName, user.getUser())); } WebServerServiceRestImpl(final WebServerService theWebServerService,
                                    final WebServerControlService theWebServerControlService,
                                    final WebServerCommandService theWebServerCommandService,
                                    final ResourceService theResourceService, GroupService groupService,
                                    final BinaryDistributionService binaryDistributionService,
                                    final HistoryFacadeService historyFacadeService
                                    ); @Override Response getWebServers(final Identifier<Group> aGroupId); @Override Response getWebServer(final Identifier<WebServer> aWsId); @Override Response createWebServer(final JsonCreateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response updateWebServer(final JsonUpdateWebServer aWebServerToCreate, final AuthenticatedUser aUser); @Override Response deleteWebServer(final Identifier<WebServer> id, boolean hardDelete, final AuthenticatedUser authUser); @Override Response controlWebServer(final Identifier<WebServer> aWebServerId,
                                     final JsonControlWebServer aWebServerToControl, final AuthenticatedUser aUser,
                                     final Boolean wait, Long waitTimeout); @Override Response generateConfig(final String webServerName); @Override Response generateAndDeployConfig(final String aWebServerName, final String resourceFileName, final AuthenticatedUser user); @Override Response generateAndDeployWebServer(final String aWebServerName, final AuthenticatedUser aUser); @Override Response getHttpdConfig(Identifier<WebServer> aWebServerId); @Override Response getResourceNames(final String wsName); @Override Response getResourceTemplate(final String wsName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String wsName, final String resourceTemplateName, final String content); @Override Response previewResourceTemplate(final String webServerName, final String fileName, final String groupName, String template);  }