@Test public void testPreviewResourceTemplate() { when(jvmService.previewResourceTemplate(anyString(), anyString(), anyString(), anyString())).thenReturn("<server>preview</server>"); Response response = jvmServiceRest.previewResourceTemplate("myFile", jvm.getJvmName(), "group1", "ServerXMLTemplate.tpl"); assertNotNull(response.getEntity()); when(jvmService.previewResourceTemplate(anyString(), anyString(), anyString(), anyString())).thenThrow(new RuntimeException("Test failed preview")); response = jvmServiceRest.previewResourceTemplate("myFile", jvm.getJvmName(), "group1", "ServerXMLTemplate.tpl"); assertNotNull(response.getEntity()); }
@Override public Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template) { LOGGER.debug("Preview resource template for JVM {} in group {} with content {}", jvmName, groupName, template); try { return ResponseBuilder.ok(jvmService.previewResourceTemplate(fileName, jvmName, groupName, template)); } catch (RuntimeException rte) { LOGGER.debug("Error previewing resource.", rte); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.INVALID_TEMPLATE, rte.getMessage())); } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template) { LOGGER.debug("Preview resource template for JVM {} in group {} with content {}", jvmName, groupName, template); try { return ResponseBuilder.ok(jvmService.previewResourceTemplate(fileName, jvmName, groupName, template)); } catch (RuntimeException rte) { LOGGER.debug("Error previewing resource.", rte); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.INVALID_TEMPLATE, rte.getMessage())); } } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template) { LOGGER.debug("Preview resource template for JVM {} in group {} with content {}", jvmName, groupName, template); try { return ResponseBuilder.ok(jvmService.previewResourceTemplate(fileName, jvmName, groupName, template)); } catch (RuntimeException rte) { LOGGER.debug("Error previewing resource.", rte); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.INVALID_TEMPLATE, rte.getMessage())); } } JvmServiceRestImpl(final JvmService theJvmService,
                              final JvmControlService theJvmControlService); }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template) { LOGGER.debug("Preview resource template for JVM {} in group {} with content {}", jvmName, groupName, template); try { return ResponseBuilder.ok(jvmService.previewResourceTemplate(fileName, jvmName, groupName, template)); } catch (RuntimeException rte) { LOGGER.debug("Error previewing resource.", rte); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.INVALID_TEMPLATE, rte.getMessage())); } } 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 previewResourceTemplate(final String jvmName, final String fileName, final String groupName, final String template) { LOGGER.debug("Preview resource template for JVM {} in group {} with content {}", jvmName, groupName, template); try { return ResponseBuilder.ok(jvmService.previewResourceTemplate(fileName, jvmName, groupName, template)); } catch (RuntimeException rte) { LOGGER.debug("Error previewing resource.", rte); return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.INVALID_TEMPLATE, rte.getMessage())); } } 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);  }