@Test public void testUpdate() throws ApplicationServiceException { when(Config.service.updateApplication(any(UpdateApplicationRequest.class), any(User.class))).thenReturn(Config.newlyCreatedApp); ArrayList<UpdateApplicationRequest> multiUpdate = new ArrayList<>(); multiUpdate.add(new UpdateApplicationRequest(Identifier.id(0L, Application.class), Identifier.id(0L, Group.class), "", "", true, true, false)); JsonUpdateApplication jsonUpdateAppRequest = new JsonUpdateApplication(); Response resp = applicationServiceRestInterface.updateApplication(jsonUpdateAppRequest, Config.authenticatedUser); assertNotNull(resp.getEntity()); ApplicationResponse appResponse = (ApplicationResponse) resp.getEntity(); Object entity = appResponse.getApplicationResponseContent(); assertEquals(Config.newlyCreatedApp, entity); }
@Override public Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser) throws ApplicationServiceException { LOGGER.info("Update Application requested: {}", anAppToUpdate); try { Application updated = service.updateApplication(anAppToUpdate.toUpdateCommand(), aUser.getUser()); return ResponseBuilder.ok(updated); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_APPLICATION, eee.getMessage(), eee)); } }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser) throws ApplicationServiceException { LOGGER.info("Update Application requested: {}", anAppToUpdate); try { Application updated = service.updateApplication(anAppToUpdate.toUpdateCommand(), aUser.getUser()); return ResponseBuilder.ok(updated); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_APPLICATION, eee.getMessage(), eee)); } } }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser) throws ApplicationServiceException { LOGGER.info("Update Application requested: {}", anAppToUpdate); try { Application updated = service.updateApplication(anAppToUpdate.toUpdateCommand(), aUser.getUser()); return ResponseBuilder.ok(updated); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_APPLICATION, eee.getMessage(), eee)); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser) throws ApplicationServiceException { LOGGER.info("Update Application requested: {}", anAppToUpdate); try { Application updated = service.updateApplication(anAppToUpdate.toUpdateCommand(), aUser.getUser()); return ResponseBuilder.ok(updated); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_APPLICATION, eee.getMessage(), eee)); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); @Override Response getApplication(Identifier<Application> anAppId); @Override Response getApplicationByName(final String name); @Override Response getApplications(Identifier<Group> aGroupId); @Override Response findApplicationsByJvmId(Identifier<Jvm> aJvmId); @Override Response createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser); @Override Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser); @Override Response removeApplication(final Identifier<Application> anAppToRemove, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, String hostName); @Override Response getResourceNames(final String appName, final String jvmName); @Override Response updateResourceTemplate(final String appName,
                                           final String resourceTemplateName,
                                           final String jvmName,
                                           final String groupName,
                                           final String content); @Override Response deployConf(final String appName, final String groupName, final String jvmName,
                               final String resourceTemplateName, final AuthenticatedUser authUser); @Override Response previewResourceTemplate(final String appName, final String groupName, final String jvmName,
                                            final String fileName,
                                            final String template); @Override Response deployConf(final String appName, final AuthenticatedUser aUser, final String hostName); @Override Response checkIfFileExists(final String filePath, final AuthenticatedUser aUser, final String hostName); }
ApplicationServiceRestImpl implements ApplicationServiceRest { @Override public Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser) throws ApplicationServiceException { LOGGER.info("Update Application requested: {}", anAppToUpdate); try { Application updated = service.updateApplication(anAppToUpdate.toUpdateCommand(), aUser.getUser()); return ResponseBuilder.ok(updated); } catch (EntityExistsException eee) { return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException( FaultType.DUPLICATE_APPLICATION, eee.getMessage(), eee)); } } ApplicationServiceRestImpl(ApplicationService applicationService,
                                      ResourceService resourceService,
                                      final GroupService groupService); @Override Response getApplication(Identifier<Application> anAppId); @Override Response getApplicationByName(final String name); @Override Response getApplications(Identifier<Group> aGroupId); @Override Response findApplicationsByJvmId(Identifier<Jvm> aJvmId); @Override Response createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser); @Override Response updateApplication(final JsonUpdateApplication anAppToUpdate, final AuthenticatedUser aUser); @Override Response removeApplication(final Identifier<Application> anAppToRemove, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, final AuthenticatedUser aUser); @Override Response deployWebArchive(final Identifier<Application> anAppToGet, String hostName); @Override Response getResourceNames(final String appName, final String jvmName); @Override Response updateResourceTemplate(final String appName,
                                           final String resourceTemplateName,
                                           final String jvmName,
                                           final String groupName,
                                           final String content); @Override Response deployConf(final String appName, final String groupName, final String jvmName,
                               final String resourceTemplateName, final AuthenticatedUser authUser); @Override Response previewResourceTemplate(final String appName, final String groupName, final String jvmName,
                                            final String fileName,
                                            final String template); @Override Response deployConf(final String appName, final AuthenticatedUser aUser, final String hostName); @Override Response checkIfFileExists(final String filePath, final AuthenticatedUser aUser, final String hostName);  }