@Test public void testUpdateResourceTemplate() { final String updateValue = "<server>update</server>"; when(jvmService.updateResourceTemplate(anyString(), anyString(), anyString())).thenReturn(updateValue); Response response = jvmServiceRest.updateResourceTemplate(jvm.getJvmName(), "ServerXMLTemplate.tpl", updateValue); assertNotNull(response.getEntity()); when(jvmService.updateResourceTemplate(anyString(), anyString(), anyString())).thenReturn(null); response = jvmServiceRest.updateResourceTemplate(jvm.getJvmName(), "ServerXMLTemplate.tpl", updateValue); assertNotNull(response.getEntity()); assertEquals(500, response.getStatus()); final ApplicationResponse applicationResponse = (ApplicationResponse) response.getEntity(); assertEquals("Failed to update the template ServerXMLTemplate.tpl for jvmName. See the log for more details.", applicationResponse.getApplicationResponseContent()); }
@Override public Response updateResourceTemplate(final String jvmName, final String resourceTemplateName, final String content) { LOGGER.info("Update the resource template {} for JVM {}", resourceTemplateName, jvmName); LOGGER.debug(content); final String someContent = jvmService.updateResourceTemplate(jvmName, resourceTemplateName, content); if (someContent != null) { return ResponseBuilder.ok(someContent); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, "Failed to update the template " + resourceTemplateName + " for " + jvmName + ". See the log for more details.")); } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateResourceTemplate(final String jvmName, final String resourceTemplateName, final String content) { LOGGER.info("Update the resource template {} for JVM {}", resourceTemplateName, jvmName); LOGGER.debug(content); final String someContent = jvmService.updateResourceTemplate(jvmName, resourceTemplateName, content); if (someContent != null) { return ResponseBuilder.ok(someContent); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, "Failed to update the template " + resourceTemplateName + " for " + jvmName + ". See the log for more details.")); } } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateResourceTemplate(final String jvmName, final String resourceTemplateName, final String content) { LOGGER.info("Update the resource template {} for JVM {}", resourceTemplateName, jvmName); LOGGER.debug(content); final String someContent = jvmService.updateResourceTemplate(jvmName, resourceTemplateName, content); if (someContent != null) { return ResponseBuilder.ok(someContent); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, "Failed to update the template " + resourceTemplateName + " for " + jvmName + ". See the log for more details.")); } } JvmServiceRestImpl(final JvmService theJvmService,
                              final JvmControlService theJvmControlService); }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateResourceTemplate(final String jvmName, final String resourceTemplateName, final String content) { LOGGER.info("Update the resource template {} for JVM {}", resourceTemplateName, jvmName); LOGGER.debug(content); final String someContent = jvmService.updateResourceTemplate(jvmName, resourceTemplateName, content); if (someContent != null) { return ResponseBuilder.ok(someContent); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, "Failed to update the template " + resourceTemplateName + " for " + jvmName + ". See the log for more details.")); } } JvmServiceRestImpl(final JvmService theJvmService,
                              final JvmControlService theJvmControlService); @Override Response getJvms(); @Override Response getJvm(final Identifier<Jvm> aJvmId); @Override Response createJvm(final JsonCreateJvm jsonCreateJvm, final AuthenticatedUser aUser); @Override Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser); @Override Response deleteJvm(final Identifier<Jvm> id, final boolean hardDelete, final AuthenticatedUser user); @Override Response controlJvm(final Identifier<Jvm> aJvmId, final JsonControlJvm aJvmToControl, Boolean wait,
                               Long waitTimeout, final AuthenticatedUser aUser); @Override Response generateAndDeployJvm(final String jvmName, final AuthenticatedUser user); @Override Response upgradeJDK(final String jvmName, final AuthenticatedUser user); @Override Response generateAndDeployFile(final String jvmName, final String fileName, AuthenticatedUser user); @Override Response diagnoseJvm(Identifier<Jvm> aJvmId, final AuthenticatedUser aUser); @Override Response getResourceNames(final String jvmName); @Override Response getResourceTemplate(final String jvmName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String jvmName, final String resourceTemplateName,
                                           final String content); @Override Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template); }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateResourceTemplate(final String jvmName, final String resourceTemplateName, final String content) { LOGGER.info("Update the resource template {} for JVM {}", resourceTemplateName, jvmName); LOGGER.debug(content); final String someContent = jvmService.updateResourceTemplate(jvmName, resourceTemplateName, content); if (someContent != null) { return ResponseBuilder.ok(someContent); } else { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.PERSISTENCE_ERROR, "Failed to update the template " + resourceTemplateName + " for " + jvmName + ". See the log for more details.")); } } JvmServiceRestImpl(final JvmService theJvmService,
                              final JvmControlService theJvmControlService); @Override Response getJvms(); @Override Response getJvm(final Identifier<Jvm> aJvmId); @Override Response createJvm(final JsonCreateJvm jsonCreateJvm, final AuthenticatedUser aUser); @Override Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser); @Override Response deleteJvm(final Identifier<Jvm> id, final boolean hardDelete, final AuthenticatedUser user); @Override Response controlJvm(final Identifier<Jvm> aJvmId, final JsonControlJvm aJvmToControl, Boolean wait,
                               Long waitTimeout, final AuthenticatedUser aUser); @Override Response generateAndDeployJvm(final String jvmName, final AuthenticatedUser user); @Override Response upgradeJDK(final String jvmName, final AuthenticatedUser user); @Override Response generateAndDeployFile(final String jvmName, final String fileName, AuthenticatedUser user); @Override Response diagnoseJvm(Identifier<Jvm> aJvmId, final AuthenticatedUser aUser); @Override Response getResourceNames(final String jvmName); @Override Response getResourceTemplate(final String jvmName, final String resourceTemplateName,
                                        final boolean tokensReplaced); @Override Response updateResourceTemplate(final String jvmName, final String resourceTemplateName,
                                           final String content); @Override Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template);  }