@Test public void testGetApplicationsByNameErrCndtn() { String noExistAppName = "notExistAppName"; setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(noExistAppName, TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) appController.getApplicationsByName(req, noExistAppName).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Application Not found with name: " + noExistAppName + " for Team: " + TEAMNAME, apiError.getStatusMessage()); }
@ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching Application object with name " + name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(name, teamName); if (application == null) { final String error = "Application Not found with name: " + name + " for Team: " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptPassword(application), HttpStatus.OK); }
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching Application object with name " + name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(name, teamName); if (application == null) { final String error = "Application Not found with name: " + name + " for Team: " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptPassword(application), HttpStatus.OK); } }
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching Application object with name " + name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(name, teamName); if (application == null) { final String error = "Application Not found with name: " + name + " for Team: " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptPassword(application), HttpStatus.OK); }  }
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching Application object with name " + name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(name, teamName); if (application == null) { final String error = "Application Not found with name: " + name + " for Team: " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptPassword(application), HttpStatus.OK); }  @ApiOperation(value = "This API returns all Application Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.GET) ResponseEntity<Object> getAllApplication(); @ApiOperation(value = "This API returns count of Application objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Application objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/applications/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns list of all Application objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given team") }) @RequestMapping(value = "/api/applications/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request); @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Application Object for given App ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App ID") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Application Objects present in Elastic Search for given App ID and App Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App ID and App Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App ID and App Category") }) @RequestMapping(value = "/api/applications/{name}/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request,
			@PathVariable("name") String name, @PathVariable("category") String category); @ApiOperation(value = "This API inserts an Application Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Application object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Application with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/application/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application,
			UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an Application Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Application objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Application with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddApplication(HttpServletRequest request,
			@RequestBody ApplicationAdapter applicationadapter); @ApiOperation(value = "This API updates an Application Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Application can be changed only by the owning team"), @ApiResponse(code = 404, message = "Applicaiton object not found in ES for given App ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id,
			@RequestBody Application toModifyApplication); @ApiOperation(value = "This API deletes an Application Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Application can be delted only by the owning team"), @ApiResponse(code = 404, message = "Applicaiton object not found in ES for given App ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API deletes all Application Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Application object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllApplications(); @ApiOperation(value = "This API returns Server Hardware details after discovery", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Server Hardware details after discovery"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 400, message = "Input Request object is not valid"), @ApiResponse(code = 404, message = "No Server Hardware details found") }) @RequestMapping(value = "/api/applications/discoverServerDetails/", method = RequestMethod.POST, produces = "application/json", headers = "Accept=application/json") ResponseEntity<Object> discoverServerDetailsForApplication(HttpServletRequest request,
			@RequestBody @Valid FuelDiscover discoverRequest); }
ApplicationRestController { @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching Application object with name " + name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(name, teamName); if (application == null) { final String error = "Application Not found with name: " + name + " for Team: " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptPassword(application), HttpStatus.OK); }  @ApiOperation(value = "This API returns all Application Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.GET) ResponseEntity<Object> getAllApplication(); @ApiOperation(value = "This API returns count of Application objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Application objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/applications/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns list of all Application objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given team") }) @RequestMapping(value = "/api/applications/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request); @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Application Object for given App ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App ID") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Application Object present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App Name") }) @RequestMapping(value = "/api/applications/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplicationsByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Application Objects present in Elastic Search for given App ID and App Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Application Object for given App ID and App Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Application object found for given App ID and App Category") }) @RequestMapping(value = "/api/applications/{name}/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request,
			@PathVariable("name") String name, @PathVariable("category") String category); @ApiOperation(value = "This API inserts an Application Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Application object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Application with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/application/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application,
			UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an Application Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Application objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Application with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddApplication(HttpServletRequest request,
			@RequestBody ApplicationAdapter applicationadapter); @ApiOperation(value = "This API updates an Application Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Application can be changed only by the owning team"), @ApiResponse(code = 404, message = "Applicaiton object not found in ES for given App ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id,
			@RequestBody Application toModifyApplication); @ApiOperation(value = "This API deletes an Application Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Application object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Application can be delted only by the owning team"), @ApiResponse(code = 404, message = "Applicaiton object not found in ES for given App ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API deletes all Application Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Application object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/applications/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllApplications(); @ApiOperation(value = "This API returns Server Hardware details after discovery", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Server Hardware details after discovery"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 400, message = "Input Request object is not valid"), @ApiResponse(code = 404, message = "No Server Hardware details found") }) @RequestMapping(value = "/api/applications/discoverServerDetails/", method = RequestMethod.POST, produces = "application/json", headers = "Accept=application/json") ResponseEntity<Object> discoverServerDetailsForApplication(HttpServletRequest request,
			@RequestBody @Valid FuelDiscover discoverRequest);  }