@Test public void testUpdateJvm() { final Set<String> groupIds = new HashSet<>(); groupIds.add("111"); final JsonUpdateJvm jsonUpdateJvm = new JsonUpdateJvm("1", name, hostName, groupIds, "5", "4", "3", "2", "1", statusPath.getUriPath(), systemProperties, userName, clearTextPassword, JDK_1_7_TEST_VERSION, APACHE_TOMCAT_7_0_55_TEST_VERSION); when(jvmService.updateJvm(any(UpdateJvmRequest.class), eq(true))).thenReturn(jvm); UpdateJvmRequest updateJvmCommand = jsonUpdateJvm.toUpdateJvmRequest(); updateJvmCommand.validate(); updateJvmCommand.hashCode(); updateJvmCommand.equals(jsonUpdateJvm.toUpdateJvmRequest()); String check = updateJvmCommand.toString(); final Response response = jvmServiceRest.updateJvm(jsonUpdateJvm, true, authenticatedUser); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); final ApplicationResponse applicationResponse = (ApplicationResponse) response.getEntity(); final Object content = applicationResponse.getApplicationResponseContent(); assertTrue(content instanceof Jvm); final Jvm received = (Jvm) content; assertEquals(jvm, received); }
@Override public Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser) { LOGGER.info("Update JVM requested: {} by user {}", aJvmToUpdate, aUser.getUser().getId()); try { return ResponseBuilder.ok(jvmService.updateJvm(aJvmToUpdate.toUpdateJvmRequest(), updateJvmPassword)); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_JVM_NAME, eee.getMessage(), eee)); } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser) { LOGGER.info("Update JVM requested: {} by user {}", aJvmToUpdate, aUser.getUser().getId()); try { return ResponseBuilder.ok(jvmService.updateJvm(aJvmToUpdate.toUpdateJvmRequest(), updateJvmPassword)); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_JVM_NAME, eee.getMessage(), eee)); } } }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser) { LOGGER.info("Update JVM requested: {} by user {}", aJvmToUpdate, aUser.getUser().getId()); try { return ResponseBuilder.ok(jvmService.updateJvm(aJvmToUpdate.toUpdateJvmRequest(), updateJvmPassword)); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_JVM_NAME, eee.getMessage(), eee)); } } JvmServiceRestImpl(final JvmService theJvmService,
                              final JvmControlService theJvmControlService); }
JvmServiceRestImpl implements JvmServiceRest { @Override public Response updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser) { LOGGER.info("Update JVM requested: {} by user {}", aJvmToUpdate, aUser.getUser().getId()); try { return ResponseBuilder.ok(jvmService.updateJvm(aJvmToUpdate.toUpdateJvmRequest(), updateJvmPassword)); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_JVM_NAME, eee.getMessage(), eee)); } } 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 updateJvm(final JsonUpdateJvm aJvmToUpdate, final boolean updateJvmPassword, final AuthenticatedUser aUser) { LOGGER.info("Update JVM requested: {} by user {}", aJvmToUpdate, aUser.getUser().getId()); try { return ResponseBuilder.ok(jvmService.updateJvm(aJvmToUpdate.toUpdateJvmRequest(), updateJvmPassword)); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_JVM_NAME, eee.getMessage(), eee)); } } 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);  }