@Test public void testCreate() { when(Config.service.createApplication(any(CreateApplicationRequest.class), any(User.class))).thenReturn(Config.newlyCreatedApp); JsonCreateApplication jsonCreateAppRequest = new JsonCreateApplication(); Response resp = applicationServiceRestInterface.createApplication(jsonCreateAppRequest, Config.authenticatedUser); assertNotNull(resp.getEntity()); ApplicationResponse appResponse = (ApplicationResponse) resp.getEntity(); Object entity = appResponse.getApplicationResponseContent(); assertEquals(Config.newlyCreatedApp, entity); assertEquals(Status.CREATED.getStatusCode(), resp.getStatus()); }
@Override public Response createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create Application requested: {}", anAppToCreate); try { Application created = service.createApplication(anAppToCreate.toCreateCommand(), aUser.getUser()); return ResponseBuilder.created(created); } 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 createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create Application requested: {}", anAppToCreate); try { Application created = service.createApplication(anAppToCreate.toCreateCommand(), aUser.getUser()); return ResponseBuilder.created(created); } 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 createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create Application requested: {}", anAppToCreate); try { Application created = service.createApplication(anAppToCreate.toCreateCommand(), aUser.getUser()); return ResponseBuilder.created(created); } 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 createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create Application requested: {}", anAppToCreate); try { Application created = service.createApplication(anAppToCreate.toCreateCommand(), aUser.getUser()); return ResponseBuilder.created(created); } 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 createApplication(final JsonCreateApplication anAppToCreate, final AuthenticatedUser aUser) { LOGGER.info("Create Application requested: {}", anAppToCreate); try { Application created = service.createApplication(anAppToCreate.toCreateCommand(), aUser.getUser()); return ResponseBuilder.created(created); } 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);  }