target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testDeletemonkeystrategyErrCndtn() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(null); setSecuirtyContext(TEAMNAME, USERNAME); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .deletemonkeystrategy(req, monkeyStrategy.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Unable to delete as Monkeystrategy with id: " + monkeyStrategy.getId() + " not found", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testDeletemonkeystrategy() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(monkeyStrategy); ResponseEntity<Object> response = monkeyStrategyController.deletemonkeystrategy(req, monkeyStrategy.getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(monkeyStrategyRepository, times(1)).delete(monkeyStrategy); }
|
@ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting monkeystrategy with id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "Unable to delete as Monkeystrategy with id: " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(monkeyStrategy.getTeamName()) && !monkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be deleted only by the owning Team " + monkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } monkeyStrategyService.delete(monkeyStrategy); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testGetFailurePointByApplicationEnvironmentAndTeamNameErrCndtn() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); Application app = new Application(); app.setTeamName("TEST"); app.setApplicationName("testApp"); Environment qaEnvronment = new Environment(); qaEnvronment.setServerList(new ArrayList<Server>()); qaEnvronment.setName("QA"); app.addEnvironment(qaEnvronment); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndTeamName(app.getApplicationName(), TEAMNAME)) .thenReturn(null); when(applicationRepository.findByApplicationNameAndTeamName(app.getApplicationName(), app.getTeamName(), new PageRequest(0, 999))).thenReturn(null); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .getFailurePointByApplicationEnvironmentAndTeamName(req, app.getApplicationName(), "QA").getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" Application Not found for name " + app.getApplicationName(), apiError.getStatusMessage()); when(applicationRepository.findByApplicationNameAndTeamName(app.getApplicationName(), TEAMNAME)) .thenReturn(app); apiError = (MessageWrapper) monkeyStrategyController .getFailurePointByApplicationEnvironmentAndTeamName(req, app.getApplicationName(), "QA1").getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Environment QA1 not found for application with name " + app.getApplicationName(), apiError.getStatusMessage()); apiError = (MessageWrapper) monkeyStrategyController .getFailurePointByApplicationEnvironmentAndTeamName(req, app.getApplicationName(), "QA").getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No Monkey Strategy found for applicationname " + app.getApplicationName() + "and environment QA", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testGetFailurePointByApplicationEnvironmentAndTeamName() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(); String osType = app.getEnvironment("QA").getServerList().get(0).getOperatingSystem(); MonkeyStrategy msHW = createMonkeyStrategy("hardwareMonkeyStrategy", TEAMNAME); MonkeyStrategy msSW = createMonkeyStrategy("softwareMonkeyStrategy", TEAMNAME); List<MonkeyStrategy> msHWList = new ArrayList<>(); msHWList.add(msHW); List<MonkeyStrategy> msSWList = new ArrayList<>(); msSWList.add(msSW); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndTeamName(app.getApplicationName(), TEAMNAME)) .thenReturn(app); when(monkeyStrategyRepository .findByOsTypeAndDefaultFlagAndGenericAndFlavorAndFailureCategoryAndFailureSubCategory(osType, "Y", "Y", "all", HARDWAREFAILURECAT, "all")).thenReturn(msHWList); when(monkeyStrategyRepository .findByOsTypeAndDefaultFlagAndGenericAndFlavorAndFailureCategoryAndFailureSubCategory(osType, "Y", "Y", "all", SOFTWARECAT, "all")).thenReturn(msSWList); @SuppressWarnings("unchecked") HashMap<String, List<FailurePoint>> response = (HashMap<String, List<FailurePoint>>) monkeyStrategyController .getFailurePointByApplicationEnvironmentAndTeamName(req, app.getApplicationName(), "QA").getBody(); assertEquals(true, response.containsKey(WEBSERVER)); assertEquals(2, response.get(WEBSERVER).size()); assertEquals("hardwareMonkeyStrategy", response.get(WEBSERVER).get(0).getFailureMode()); assertEquals("softwareMonkeyStrategy", response.get(WEBSERVER).get(1).getFailureMode()); }
|
@ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname) { logger.debug("Fetching Monkey Strategies for application: %s , and environment : %s", applicationname, environmentname); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndTeamName(applicationname, teamName); if (application == null) { final String error = " Application Not found for name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getEnvironment(environmentname) == null) { final String error = "Environment " + environmentname + " not found for application with name " + applicationname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HashMap<String, List<FailurePoint>> serverFailurePointMap = (HashMap<String, List<FailurePoint>>) monkeyStrategyService .findMonkeyStrategyByOSTypeAndProcessName(application.getCategory(), application.getEnvironment(environmentname).getServerList()); if (serverFailurePointMap == null || serverFailurePointMap.isEmpty()) { final String error = "No Monkey Strategy found for applicationname " + applicationname + "and environment " + environmentname; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(serverFailurePointMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testListAllFailurePoints() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findAll()).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList = (List<FailurePoint>) failurePointController.listAllFailurePoints() .getBody(); assertEquals(1, failurePointList.size()); assertEquals(MonkeyType.CHAOS, failurePointList.get(0).getMonkeyType()); assertEquals(FPNAME, failurePointList.get(0).getName()); }
|
@ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testListAllFailurePointsErrCond() { List<FailurePoint> fpList = new ArrayList<>(); when(failurePointRepository.findAll()).thenReturn(fpList); MessageWrapper apiError = (MessageWrapper) failurePointController.listAllFailurePoints().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No FailurePoint(s) found !!!", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllFailurePoints() { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findAll()); if (failurePoints.isEmpty()) { final String error = " No FailurePoint(s) found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); FailurePoint failurePoint = (FailurePoint) failurePointController.getFailurePoint(fp.getId()).getBody(); assertEquals(MonkeyType.CHAOS, failurePoint.getMonkeyType()); assertEquals(FPNAME, failurePoint.getName()); }
|
@ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointErrCond() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) failurePointController.getFailurePoint(fp.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("FailurePoint Not found for id " + fp.getId(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id) { FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "FailurePoint Not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointsByName() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findByName(fp.getName())).thenReturn(fp); FailurePoint failurePoint = (FailurePoint) failurePointController.getFailurePointsByName(fp.getName()) .getBody(); assertEquals(MonkeyType.CHAOS, failurePoint.getMonkeyType()); assertEquals(FPNAME, failurePoint.getName()); }
|
@ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointsByNameErrCond() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findByName(fp.getName())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) failurePointController.getFailurePointsByName(fp.getName()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" FailurePoint Not found for name " + fp.getName(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name) { FailurePoint failurePoint = failurePointService.findByName(name); if (failurePoint == null) { final String error = " FailurePoint Not found for name " + name; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testListAllMonkeyStrategies() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); when(monkeyStrategyRepository.findAll()).thenReturn(monkeyStrategies); @SuppressWarnings("unchecked") List<MonkeyStrategy> monkeyStrategiesList = (List<MonkeyStrategy>) monkeyStrategyController .listAllMonkeyStrategies().getBody(); assertEquals(1, monkeyStrategiesList.size()); assertEquals(MONKEYSTRATEGYNAME, monkeyStrategiesList.get(0).getMonkeyStrategyName()); assertEquals(TEAMNAME, monkeyStrategiesList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testGetFailurePointByCategory() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findByCategory(fp.getCategory())).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList = (List<FailurePoint>) failurePointController .getFailurePointByCategory(fp.getCategory()).getBody(); assertEquals(1, failurePointList.size()); assertEquals(MonkeyType.CHAOS, failurePointList.get(0).getMonkeyType()); assertEquals(FPNAME, failurePointList.get(0).getName()); assertEquals("fpCategory", failurePointList.get(0).getCategory()); }
|
@ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointByCategoryErrCond() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); when(failurePointRepository.findByCategory(fp.getCategory())).thenReturn(fpList); MessageWrapper apiError = (MessageWrapper) failurePointController.getFailurePointByCategory(fp.getCategory()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("failurePoints not found with category " + fp.getCategory(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByCategory(category)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found with category " + category; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointByRole() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp); when(failurePointRepository.findByRole(fp.getRole())).thenReturn(fpList); @SuppressWarnings("unchecked") List<FailurePoint> failurePointList = (List<FailurePoint>) failurePointController .getFailurePointByRole(fp.getRole()).getBody(); assertEquals(1, failurePointList.size()); assertEquals(MonkeyType.CHAOS, failurePointList.get(0).getMonkeyType()); assertEquals(FPNAME, failurePointList.get(0).getName()); assertEquals("role", failurePointList.get(0).getRole()); }
|
@ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetFailurePointByRoleErrCond() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); when(failurePointRepository.findByRole(fp.getRole())).thenReturn(fpList); MessageWrapper apiError = (MessageWrapper) failurePointController.getFailurePointByRole(fp.getRole()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("failurePoints not found for role " + fp.getRole(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role) { List<FailurePoint> failurePoints = Lists.newArrayList(failurePointService.findByRole(role)); if (failurePoints == null || failurePoints.isEmpty()) { final String error = "failurePoints not found for role " + role; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(failurePoints, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testAddFailurePoint() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findByName(fp.getName())).thenReturn(null); when(failurePointRepository.save(fp)).thenReturn(fp); ResponseEntity<Object> response = failurePointController.addFailurePoint(fp, ucBuilder); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
|
@ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testAddFailurePointErrCndtn() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); fp.setName(""); MessageWrapper apiError = (MessageWrapper) failurePointController.addFailurePoint(fp, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("FailurePoint name cannot be empty", apiError.getStatusMessage()); fp.setName("fpName"); when(failurePointRepository.findByName(fp.getName())).thenReturn(fp); apiError = (MessageWrapper) failurePointController.addFailurePoint(fp, ucBuilder).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("FailurePoint already exist with name " + fp.getName(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint, UriComponentsBuilder ucBuilder) { logger.debug("Creating a failurePoint with name:" + failurePoint.getName()); if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint already exist with name " + failurePoint.getName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id -->" + failurePoint.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/failurePoint/{id}").buildAndExpand(failurePoint.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testBulkAddFailurePoint() { FailurePoint fp1 = createFailurePoint(FPNAME, TEAMNAME); FailurePoint fp2 = createFailurePoint("fpName2", TEAMNAME); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp1); fpList.add(fp2); FailurePointAdapter fpAdapter = new FailurePointAdapter(); fpAdapter.setFailurePoints(fpList); when(failurePointRepository.findByName(fp1.getName())).thenReturn(null); when(failurePointRepository.save(fp1)).thenReturn(fp1); when(failurePointRepository.findByName(fp2.getName())).thenReturn(null); when(failurePointRepository.save(fp2)).thenReturn(fp2); ResponseEntity<Object> response = failurePointController.bulkaddFailurePoint(fpAdapter); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
|
@ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testBulkAddFailurePointErrCndtn() { FailurePointAdapter fpAdapter = null; MessageWrapper apiError = (MessageWrapper) failurePointController.bulkaddFailurePoint(fpAdapter).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("NULL request received to add failurePoint", apiError.getStatusMessage()); FailurePoint fp1 = createFailurePoint(FPNAME, TEAMNAME); FailurePoint fp2 = createFailurePoint("fpName2", TEAMNAME); fp1.setName(""); List<FailurePoint> fpList = new ArrayList<>(); fpList.add(fp1); fpList.add(fp2); fpAdapter = new FailurePointAdapter(); fpAdapter.setFailurePoints(fpList); apiError = (MessageWrapper) failurePointController.bulkaddFailurePoint(fpAdapter).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("FailurePoint name cannot be empty", apiError.getStatusMessage()); fp1.setName("fpName"); when(failurePointRepository.findByName(fp1.getName())).thenReturn(fp1); apiError = (MessageWrapper) failurePointController.bulkaddFailurePoint(fpAdapter).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("FailurePoint with name " + fp1.getName() + " already exist", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter) { if (failurePointadapter == null) { final String error = "NULL request received to add failurePoint"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("bulk inserting failurePoints: %s", failurePointadapter.getFailurePoints().size()); for (FailurePoint failurePoint : failurePointadapter.getFailurePoints()) { if (failurePoint.getName() == null || "".equals(failurePoint.getName().trim())) { final String error = "FailurePoint name cannot be empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (failurePointService.insert(failurePoint) == null) { final String error = "FailurePoint with name " + failurePoint.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("failurePoint saved in ES with id: " + failurePoint.getId()); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testUpdateFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); when(failurePointRepository.save(fp)).thenReturn(fp); ResponseEntity<Object> response = failurePointController.updateFailurePoint(fp.getId(), fp); assertEquals(HttpStatus.OK, response.getStatusCode()); }
|
@ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testUpdateFailurePointErrCndtn() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) failurePointController.updateFailurePoint(fp.getId(), fp).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("FailurePoint with id " + fp.getId() + " not found", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id, @RequestBody FailurePoint toModifyFailurePoint) { logger.debug("Updating FailurePoint : %s ", id); FailurePoint currentFailurePoint = failurePointService.findOne(id); if (currentFailurePoint == null) { final String error = "FailurePoint with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyFailurePoint.setId(id); failurePointService.update(toModifyFailurePoint); return new ResponseEntity<>(toModifyFailurePoint, HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testListAllMonkeyStrategiesErrCond() { List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); when(monkeyStrategyRepository.findAll()).thenReturn(monkeyStrategies); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController.listAllMonkeyStrategies().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No monkeyStrategies found ", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) public ResponseEntity<Object> listAllMonkeyStrategies() { List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllMonkeyStrategies()); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = " No monkeyStrategies found "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testDeleteFailurePoint() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(fp); ResponseEntity<Object> response = failurePointController.deleteFailurePoint(fp.getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(failurePointRepository, times(1)).delete(fp); }
|
@ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testDeleteFailurePointErrCndtn() { FailurePoint fp = createFailurePoint(FPNAME, TEAMNAME); when(failurePointRepository.findOne(fp.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) failurePointController.deleteFailurePoint(fp.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Unable to delete. FailurePoint not found with id " + fp.getId(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id) { logger.debug("Deleting FailurePoint with id : %s ", id); FailurePoint failurePoint = failurePointService.findOne(id); if (failurePoint == null) { final String error = "Unable to delete. FailurePoint not found with id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } failurePointService.delete(failurePoint); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testDeleteAllFailurePoint() { ResponseEntity<Object> response = failurePointController.deleteAllFailurePoints(); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(failurePointRepository, times(1)).deleteAll(); }
|
@ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllFailurePoints() { logger.debug("Deleting All FailurePoints"); failurePointService.deleteAllFailurePoint(); return new ResponseEntity<>(HttpStatus.OK); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllFailurePoints() { logger.debug("Deleting All FailurePoints"); failurePointService.deleteAllFailurePoint(); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllFailurePoints() { logger.debug("Deleting All FailurePoints"); failurePointService.deleteAllFailurePoint(); return new ResponseEntity<>(HttpStatus.OK); } }
|
FailurePointRestController { @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllFailurePoints() { logger.debug("Deleting All FailurePoints"); failurePointService.deleteAllFailurePoint(); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
FailurePointRestController { @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllFailurePoints() { logger.debug("Deleting All FailurePoints"); failurePointService.deleteAllFailurePoint(); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all FailurePoint Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all FailurePoint Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found") }) @RequestMapping(value = "/api/failurepoints/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllFailurePoints(); @ApiOperation(value = "This API returns single FailurePoint Objects present in Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single FailurePoint Object for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint ID") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API returns single FailurePoint Object present in Elastic Search for given FailurePoint Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Object for given FailurePoint Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Name") }) @RequestMapping(value = "/api/failurepoints/name/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointsByName(@PathVariable("name") String name); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint Category", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint Category"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint Category") }) @RequestMapping(value = "/api/failurepoints/category/{category}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByCategory(@PathVariable("category") String category); @ApiOperation(value = "This API returns FailurePoint Objects present in Elastic Search for given FailurePoint role", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned FailurePoint Objects for given FailurePoint role"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No FailurePoint object found for given FailurePoint role") }) @RequestMapping(value = "/api/failurepoints/role/{role}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByRole(@PathVariable("role") String role); @ApiOperation(value = "This API inserts a FailurePoint Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoint/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addFailurePoint(@RequestBody FailurePoint failurePoint,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API do bulk insertion of an FailurePoint Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "FailurePoint objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "FailurePoint 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/failurepoints/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddFailurePoint(@RequestBody FailurePointAdapter failurePointadapter); @ApiOperation(value = "This API updates a FailurePoint Objects into Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint objects successfully updated into ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation "), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateFailurePoint(@PathVariable("id") String id,
@RequestBody FailurePoint toModifyFailurePoint); @ApiOperation(value = "This API deletes a FailurePoint Objects from Elastic Search for given FailurePoint ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "FailurePoint object successfully deleted from ES for given FailurePoint ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "FailurePoint object not found in ES for given FailurePoint ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/failurepoints/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteFailurePoint(@PathVariable("id") String id); @ApiOperation(value = "This API deletes all FailurePoint Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All FailurePoint 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/failurepoints/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllFailurePoints(); }
|
@Test public void testGetAllUsers() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<TeamUser> teamUserList = new ArrayList<>(); teamUserList.add(teamUser); when(teamUserRepository.findAll()).thenReturn(teamUserList); @SuppressWarnings("unchecked") List<TeamUser> getAllUsers = (List<TeamUser>) teamUserController.getAllUsers().getBody(); assertEquals(1, getAllUsers.size()); assertEquals(USERNAME, getAllUsers.get(0).getUserName()); assertEquals(TEAMNAME, getAllUsers.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testGetAllUsersErrCndtn() { List<TeamUser> teamUserList = new ArrayList<>(); when(teamUserRepository.findAll()).thenReturn(teamUserList); MessageWrapper apiError = (MessageWrapper) teamUserController.getAllUsers().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No User Found in TeamUser repository", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testGetCurrentTeamOfUser() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); TeamUser user = (TeamUser) teamUserController.getCurrentTeamOfUser(req).getBody(); assertEquals(USERNAME, user.getUserName()); assertEquals(TEAMNAME, user.getTeamName()); assertEquals(ROLE, user.getRoles()); }
|
@ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testGetCurrentTeamOfUserErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(null); MessageWrapper apiError = (MessageWrapper) teamUserController.getCurrentTeamOfUser(req).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("TeamUser Not found for a User.", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request) { logger.debug("Fetching Current Team for user name."); TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser Not found for a User."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testUpdateTeamOfUserErrCndtn() { MessageWrapper apiError = (MessageWrapper) teamUserController.updateTeamOfUser(req, "").getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("TeamUser cannot be modified as new Team Name is null", apiError.getStatusMessage()); String newTeamName = "newTeamName"; setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(null); apiError = (MessageWrapper) teamUserController.updateTeamOfUser(req, newTeamName).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("TeamUser object not found in ES Repository.", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testUpdateTeamOfUser() { String newTeamName = "newTeamName"; setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(teamUserRepository.findOne(teamUser.getId())).thenReturn(teamUser); when(teamUserRepository.save(teamUser)).thenReturn(teamUser); TeamUser user = (TeamUser) teamUserController.updateTeamOfUser(req, newTeamName).getBody(); assertEquals(USERNAME, user.getUserName()); assertEquals(newTeamName, user.getTeamName()); assertEquals(ROLE, user.getRoles()); }
|
@ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
TeamUserController { @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request, @PathVariable("newteamname") String newteamname) { if (newteamname == null || "".equals(newteamname.trim())) { final String error = "TeamUser cannot be modified as new Team Name is null"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } TeamUser teamUser = userDetailsService.getCurrentTeamForUser(request); if (teamUser == null) { final String error = "TeamUser object not found in ES Repository."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("Updating User %s team : %s ", teamUser.getUserName(), newteamname); teamUser.setTeamName(newteamname); userDetailsService.update(teamUser); return new ResponseEntity<>(teamUser, HttpStatus.OK); } @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
@PathVariable("newteamname") String newteamname); }
|
@Test public void testListEvents() { EventRecorder eventRecorder = createEvent(TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events.add(eventRecorder); when(eventRepository.findAll()).thenReturn(events); @SuppressWarnings("unchecked") List<EventRecorder> eventLists = (List<EventRecorder>) eventController.listEvents().getBody(); assertEquals(1, eventLists.size()); assertEquals(EventStatus.COMPLETED, eventLists.get(0).getEventStatusType()); assertEquals(TEAMNAME, eventLists.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListAllMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))) .thenReturn(monkeyStrategyPage); @SuppressWarnings("unchecked") List<MonkeyStrategy> msList = (List<MonkeyStrategy>) monkeyStrategyController.listAllMonkeyStrategy(req) .getBody(); assertEquals(1, msList.size()); assertEquals(MONKEYSTRATEGYNAME, msList.get(0).getMonkeyStrategyName()); assertEquals(TEAMNAME, msList.get(0).getTeamName()); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); monkeyStrategies.add(createMonkeyStrategy("TestSecondMonkeyStrategy", "TEST1")); when(monkeyStrategyRepository.findAll()).thenReturn(monkeyStrategies); @SuppressWarnings("unchecked") List<MonkeyStrategy> alphaMSList = (List<MonkeyStrategy>) monkeyStrategyController.listAllMonkeyStrategy(req) .getBody(); assertEquals(2, alphaMSList.size()); assertEquals(MONKEYSTRATEGYNAME, alphaMSList.get(0).getMonkeyStrategyName()); assertEquals(TEAMNAME, alphaMSList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testListEventsErrCond() { List<EventRecorder> events = new ArrayList<>(); when(eventRepository.findAll()).thenReturn(events); MessageWrapper apiError = (MessageWrapper) eventController.listEvents().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No events found !!!", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvents() { List<EventRecorder> events = Lists.newArrayList(eventService.findAll()); if (events.isEmpty()) { final String error = "No events found !!!"; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListAllEvents() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events.add(eventRecorder); Page<EventRecorder> eventRecorderPage = new PageImpl<>(events); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(eventRecorderPage); @SuppressWarnings("unchecked") List<EventRecorder> eventList = (List<EventRecorder>) eventController.listAllEvents(req).getBody(); assertEquals(1, eventList.size()); assertEquals(EventStatus.COMPLETED, eventList.get(0).getEventStatusType()); assertEquals(TEAMNAME, eventList.get(0).getTeamName()); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); events = new ArrayList<>(); events.add(createEvent(ALPHATEAMNAME)); when(eventRepository.findAll()).thenReturn(events); @SuppressWarnings("unchecked") List<EventRecorder> alphaEventList = (List<EventRecorder>) eventController.listAllEvents(req).getBody(); assertEquals(1, alphaEventList.size()); assertEquals(ALPHATEAMNAME, alphaEventList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListAllEventsErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<EventRecorder> events = new ArrayList<>(); Page<EventRecorder> eventRecorderPage = new PageImpl<>(events); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(eventRecorderPage); MessageWrapper apiError = (MessageWrapper) eventController.listAllEvents(req).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No events found for team " + TEAMNAME, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllEvents(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findAllByTeamName(teamName)); if (events.isEmpty()) { final String error = "No events found for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Map<String, List<EventRecorder>> eventListMap = new HashMap<>(); for (EventRecorder eventRecorder : events) { org.joda.time.DateTime dt = new org.joda.time.DateTime(eventRecorder.field(TIMESTAMP)); eventRecorder.fields().put(TIMESTAMP, dt.toString("yyyy-MM-dd HH:mm:ss.SSS")); String eventTimestamp = eventRecorder.field(TIMESTAMP); if (eventListMap.containsKey(eventTimestamp)) { eventListMap.get(eventTimestamp).add(eventRecorder); } else { List<EventRecorder> eventRecorderList = new ArrayList<>(); eventRecorderList.add(eventRecorder); eventListMap.put(eventTimestamp, eventRecorderList); } } eventListMap.forEach((k, v) -> { v.forEach(eventRecorder -> { eventRecorder.setExecSequence( (null == eventRecorder.getExecSequence() || eventRecorder.getExecSequence().isEmpty()) ? "0" : eventRecorder.getExecSequence()); }); }); eventListMap.forEach((k, v) -> v.sort(Comparator.comparing(EventRecorder::getExecSequence))); List<EventRecorder> finalEventRecorderList = new ArrayList<>(); eventListMap.forEach((k, v) -> { EventRecorder newEvent = new EventRecorder(); int i = 0; for (EventRecorder eventRecorder : v) { String eventStatus = "*** Script Execution O/P for Monkey Strategy: " + eventRecorder.field("monkeyStrategy") + " *** \n"; if (i == 0) { newEvent = eventRecorder; newEvent.setEventStatus(eventStatus + eventRecorder.getEventStatus() + "\n\n"); } else { newEvent.setEventStatus(newEvent.getEventStatus() + eventStatus + eventRecorder.getEventStatus()+ "\n\n"); newEvent.fields().put("monkeyStrategy", newEvent.field("monkeyStrategy") + ", " + eventRecorder.field("monkeyStrategy")); newEvent.fields().put("monkeyType", newEvent.field("monkeyType") + ", " + eventRecorder.field("monkeyType")); newEvent.setExecStatus("Failed".equalsIgnoreCase(eventRecorder.getExecStatus()) ? "Failed" : newEvent.getExecStatus()); } i++; } finalEventRecorderList.add(newEvent); }); return new ResponseEntity<>(finalEventRecorderList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListLatestEventsByAppName() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); EventRecorder eventSecondRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<EventRecorder> events = new ArrayList<>(); events.add(eventRecorder); events.add(eventSecondRecorder); Page<EventRecorder> eventRecorderPage = new PageImpl<>(events); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findByAppName(TEAMNAME, eventRecorder.field(APPNAME), new PageRequest(0, 9999))) .thenReturn(eventRecorderPage); @SuppressWarnings("unchecked") Map<String, EventRecorder> latestEventMap = (Map<String, EventRecorder>) eventController .listLatestEventsByAppName(req, eventRecorder.field(APPNAME)).getBody(); assertEquals(1, latestEventMap.size()); assertEquals(EventStatus.COMPLETED, latestEventMap.get(eventRecorder.field("name")).getEventStatusType()); }
|
@ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListLatestEventsByAppNameErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); List<EventRecorder> events = new ArrayList<>(); Page<EventRecorder> eventRecorderPage = new PageImpl<>(events); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findByAppName(TEAMNAME, eventRecorder.field(APPNAME), new PageRequest(0, 9999))) .thenReturn(eventRecorderPage); MessageWrapper apiError = (MessageWrapper) eventController .listLatestEventsByAppName(req, eventRecorder.field(APPNAME)).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No events found for team " + TEAMNAME + " and for Application Name: " + eventRecorder.field(APPNAME), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Listing Latest Events for given application: %s", applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<EventRecorder> events = Lists.newArrayList(eventService.findByAppName(teamName, applicationName)); Map<String, EventRecorder> latestEventMap = new HashMap<>(); if (!events.isEmpty()) { setLatestEventMap(latestEventMap, events); } if (latestEventMap.isEmpty()) { final String error = " No events found for team " + teamName + " and for Application Name: " + applicationName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(latestEventMap, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListEvent() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findOneForTeam(eventRecorder.getId(), TEAMNAME)).thenReturn(eventRecorder); EventRecorder event = (EventRecorder) eventController.listEvent(req, eventRecorder.getId()).getBody(); assertEquals("eventID", event.getId()); assertEquals(TEAMNAME, event.getTeamName()); }
|
@ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListEventErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findOneForTeam(eventRecorder.getId(), TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) eventController.listEvent(req, eventRecorder.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No event found for team " + TEAMNAME + " and id " + eventRecorder.getId(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Listing event for id %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No event found for team " + teamName + " and id " + id; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(event, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testGetstatusupdateforevent() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findOneForTeam(eventRecorder.getId(), TEAMNAME)).thenReturn(eventRecorder); EventStatusUpdate update = (EventStatusUpdate) eventController .getstatusupdateforevent(req, eventRecorder.getId()).getBody(); assertEquals("Latest Event Status for an Event", update.getStatusString()); }
|
@ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testGetstatusupdateforeventErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); EventRecorder eventRecorder = createEvent(TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(eventRepository.findOneForTeam(eventRecorder.getId(), TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) eventController.getstatusupdateforevent(req, eventRecorder.getId()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No events found !!! for team " + TEAMNAME, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); EventRecorder event = eventService.findOneForTeam(id, teamName); if (event == null) { final String error = "No events found !!! for team " + teamName; final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } EventStatusUpdate update = event.getEventStatusUpdate(); if (update == null) logger.debug(" No update"); return new ResponseEntity<>(update, HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(eventRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(eventRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); String eventCount = (String) eventController.countByTeamName(req).getBody(); assertEquals("1", eventCount); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); eventCount = (String) eventController.countByTeamName(req).getBody(); assertEquals("2", eventCount); }
|
@ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); logger.debug("count of Events for team %s", teamName); Long count = eventService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); }
|
EventRestController { @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); logger.debug("count of Events for team %s", teamName); Long count = eventService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); logger.debug("count of Events for team %s", teamName); Long count = eventService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
EventRestController { @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); logger.debug("count of Events for team %s", teamName); Long count = eventService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
EventRestController { @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); logger.debug("count of Events for team %s", teamName); Long count = eventService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Event Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Event Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found") }) @RequestMapping(value = "/api/events/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvents(); @ApiOperation(value = "This API returns list of all Event objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Application Event for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given team") }) @RequestMapping(value = "/api/events/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllEvents(HttpServletRequest request); @ApiOperation(value = "This API returns single Event Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Event Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given Event ID") }) @RequestMapping(value = "/api/events/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listEvent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns Event Status Objects present in Elastic Search for given Event ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Event Status Object for given Event ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event Status object found for given Event ID") }) @RequestMapping(value = "/api/events/status/{id}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> getstatusupdateforevent(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns count of Event objects available in Elastic Search for given team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Event objects for given 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/events/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Latest Events per Scenario present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Latest Events per Scenario for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Event object found for given App Name") }) @RequestMapping(value = "/api/events/latestevent/{applicationName}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listLatestEventsByAppName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); }
|
@Test public void testListAllMonkeyStrategyErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))) .thenReturn(monkeyStrategyPage); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController.listAllMonkeyStrategy(req).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No monkeyStrategies found for Team " + TEAMNAME, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<MonkeyStrategy> monkeyStrategies = Lists.newArrayList(monkeyStrategyService.findAllForTeam(teamName)); if (monkeyStrategies == null || monkeyStrategies.isEmpty()) { final String error = "No monkeyStrategies found 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<>(monkeyStrategies, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testGetAllApplication() { Application app = createApplication(APPNAME, TEAMNAME); List<Application> applications = new ArrayList<>(); applications.add(app); when(applicationRepository.findAll()).thenReturn(applications); @SuppressWarnings("unchecked") List<Application> appList = (List<Application>) appController.getAllApplication().getBody(); assertEquals(1, appList.size()); assertEquals(APPNAME, appList.get(0).getApplicationName()); assertEquals(TEAMNAME, appList.get(0).getTeamName()); }
|
@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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), 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 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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), 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); }
|
@Test public void testGetAllApplicationErrCond() { List<Application> applications = new ArrayList<>(); when(applicationRepository.findAll()).thenReturn(applications); MessageWrapper apiError = (MessageWrapper) appController.getAllApplication().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No Applications found !!! ", apiError.getStatusMessage()); }
|
@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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), 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 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) public ResponseEntity<Object> getAllApplication() { List<Application> applications = Lists.newArrayList(applicationService.findAllApplications()); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! "; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(decryptAllApplicationPassword(applications), 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); }
|
@Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(applicationRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(applicationRepository.count()).thenReturn((long) 1); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); String appCount = (String) appController.countByTeamName(req).getBody(); assertEquals("1", appCount); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); appCount = (String) appController.countByTeamName(req).getBody(); assertEquals("1", appCount); }
|
@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") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = applicationService.countByTeamName(teamName); logger.debug("count of applications for team -->" + teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = applicationService.countByTeamName(teamName); logger.debug("count of applications for team -->" + teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = applicationService.countByTeamName(teamName); logger.debug("count of applications for team -->" + teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = applicationService.countByTeamName(teamName); logger.debug("count of applications for team -->" + teamName); return new ResponseEntity<>(count.toString(), 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 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") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = applicationService.countByTeamName(teamName); logger.debug("count of applications for team -->" + teamName); return new ResponseEntity<>(count.toString(), 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); }
|
@Test public void testGetAllApplicationsForTeam() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<Application> applications = new ArrayList<>(); applications.add(app); Page<Application> appPage = new PageImpl<>(applications); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(appPage); @SuppressWarnings("unchecked") List<Application> appList = (List<Application>) appController.getAllApplicationsForTeam(req).getBody(); assertEquals(1, appList.size()); assertEquals(APPNAME, appList.get(0).getApplicationName()); assertEquals(TEAMNAME, appList.get(0).getTeamName()); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); applications.add(createApplication("TestSecondApp", "TEST1")); when(applicationRepository.findAll()).thenReturn(applications); @SuppressWarnings("unchecked") List<Application> alphaAppList = (List<Application>) appController.getAllApplicationsForTeam(req).getBody(); assertEquals(2, alphaAppList.size()); assertEquals(APPNAME, alphaAppList.get(0).getApplicationName()); assertEquals(TEAMNAME, alphaAppList.get(0).getTeamName()); }
|
@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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), 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 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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), 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); }
|
@Test public void testGetAllApplicationsForTeamErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<Application> applications = new ArrayList<>(); Page<Application> appPage = new PageImpl<>(applications); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(appPage); MessageWrapper apiError = (MessageWrapper) appController.getAllApplicationsForTeam(req).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No Applications found !!! for Team " + TEAMNAME, apiError.getStatusMessage()); }
|
@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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), 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 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") public ResponseEntity<Object> getAllApplicationsForTeam(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Application> applications = Lists.newArrayList(applicationService.findAllForTeam(teamName)); if (applications == null || applications.isEmpty()) { final String error = " No Applications found !!! 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<>(decryptAllApplicationPassword(applications), 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); }
|
@Test public void testgetApplication() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(app.getId(), TEAMNAME)).thenReturn(app); Application getApp = (Application) appController.getApplication(req, app.getId()).getBody(); assertEquals(TESTAPPID, getApp.getId()); assertEquals(APPNAME, getApp.getApplicationName()); assertEquals(TEAMNAME, getApp.getTeamName()); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); when(applicationRepository.findOne(app.getId())).thenReturn(app); getApp = (Application) appController.getApplication(req, app.getId()).getBody(); assertEquals(TESTAPPID, getApp.getId()); assertEquals(APPNAME, getApp.getApplicationName()); assertEquals(TEAMNAME, getApp.getTeamName()); }
|
@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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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); }
|
@Test public void testgetApplicationErrCndtn() { String appID = "notExistAppID"; setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(appID, TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) appController.getApplication(req, appID).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Application Not found for id " + appID, apiError.getStatusMessage()); }
|
@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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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 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) public ResponseEntity<Object> getApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching Application Object with id " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Application Not found for id " + id; 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); }
|
@Test public void testGetApplicationsByName() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndTeamName(app.getApplicationName(), TEAMNAME)) .thenReturn(app); Application getApp = (Application) appController.getApplicationsByName(req, app.getApplicationName()).getBody(); assertEquals(APPNAME, getApp.getApplicationName()); assertEquals(TEAMNAME, getApp.getTeamName()); List<Application> applications = new ArrayList<>(); applications.add(app); Page<Application> appPage = new PageImpl<>(applications); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); when(applicationRepository.findByApplicationName(app.getApplicationName(), new PageRequest(0, 999))) .thenReturn(appPage); getApp = (Application) appController.getApplicationsByName(req, app.getApplicationName()).getBody(); assertEquals(APPNAME, getApp.getApplicationName()); assertEquals(TEAMNAME, getApp.getTeamName()); }
|
@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); }
|
@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); }
|
@Test public void testGetApplicationByNameAndCategory() { setSecuirtyContext(TEAMNAME, USERNAME); Application app = createApplication(APPNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndCategoryAndTeamName(app.getApplicationName(), app.getCategory(), TEAMNAME)).thenReturn(app); Application getApp = (Application) appController .getApplicationByNameAndCategory(req, app.getApplicationName(), app.getCategory()).getBody(); assertEquals(APPNAME, getApp.getApplicationName()); assertEquals(TEAMNAME, getApp.getTeamName()); assertEquals(APPCATEGORY, getApp.getCategory()); }
|
@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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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); }
|
@Test public void testListAllMonkeyTypes() { @SuppressWarnings("unchecked") List<String> monkeyTypeList = (List<String>) monkeyStrategyController.listAllMonkeyTypes().getBody(); assertEquals(8, monkeyTypeList.size()); assertEquals(MonkeyType.CHAOS, monkeyTypeList.get(0)); }
|
@ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyTypes() { return new ResponseEntity<>(Arrays.asList(MonkeyType.values()), HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyTypes() { return new ResponseEntity<>(Arrays.asList(MonkeyType.values()), HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyTypes() { return new ResponseEntity<>(Arrays.asList(MonkeyType.values()), HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyTypes() { return new ResponseEntity<>(Arrays.asList(MonkeyType.values()), HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllMonkeyTypes() { return new ResponseEntity<>(Arrays.asList(MonkeyType.values()), HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testGetApplicationByNameAndCategoryErrCndtn() { String noExistAppName = "nonExistAppName"; String category = "nonExistCategory"; setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndCategoryAndTeamName(noExistAppName, category, TEAMNAME)) .thenReturn(null); MessageWrapper apiError = (MessageWrapper) appController .getApplicationByNameAndCategory(req, noExistAppName, category).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("application with name " + noExistAppName + " and category " + category + " not found " + " for Team " + TEAMNAME, apiError.getStatusMessage()); }
|
@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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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 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) public ResponseEntity<Object> getApplicationByNameAndCategory(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("category") String category) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findByApplicationNameAndCategoryAndTeamName(name, category, teamName); if (application == null) { final String error = "application with name " + name + " and category " + category + " not found " + " for Team " + teamName; 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); }
|
@Test public void testAddApplicationErrCndtn() { Application addApp = null; UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); MessageWrapper apiError = (MessageWrapper) appController.addApplication(req, addApp, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("NULL request received to add application", apiError.getStatusMessage()); addApp = createApplication(APPNAME, TEAMNAME); addApp.setApplicationName(""); apiError = (MessageWrapper) appController.addApplication(req, addApp, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("Application name is empty", apiError.getStatusMessage()); setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); addApp = createApplication(APPNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndTeamName(APPNAME, TEAMNAME)).thenReturn(addApp); apiError = (MessageWrapper) appController.addApplication(req, addApp, ucBuilder).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("Application with name " + addApp.getApplicationName() + " already exist", apiError.getStatusMessage()); }
|
@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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @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 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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @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); }
|
@Test public void testAddApplication() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); Application addApp = createApplication(APPNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findByApplicationNameAndTeamName(APPNAME, TEAMNAME)).thenReturn(null); when(applicationRepository.save(addApp)).thenReturn(addApp); ResponseEntity<Object> response = appController.addApplication(req, addApp, ucBuilder); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
|
@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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ApplicationRestController { @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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @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 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) public ResponseEntity<Object> addApplication(HttpServletRequest request, @RequestBody Application application, UriComponentsBuilder ucBuilder) { if (application == null) { final String error = "NULL request received to add application"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (application.getApplicationName() == null || "".equals(application.getApplicationName().trim())) { final String error = "Application name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); application.setTeamName(teamName); if (applicationService.insertForTeam(application, teamName) == null) { final String error = "Application with name " + application.getApplicationName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/applications/{id}").buildAndExpand(application.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @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); }
|
@Test public void testUpdateApplicationErrCndtn() { Application addApp = createApplication(APPNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(addApp.getId(), TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) appController.updateApplication(req, addApp.getId(), addApp) .getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("Application can be changed only by the owning Team -->" + addApp.getTeamName() + "<--", apiError.getStatusMessage()); setSecuirtyContext(TEAMNAME, USERNAME); teamUser.setTeamName(TEAMNAME); apiError = (MessageWrapper) appController.updateApplication(req, addApp.getId(), addApp).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Application with id " + addApp.getId() + " not found", apiError.getStatusMessage()); }
|
@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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, 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 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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, 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); }
|
@Test public void testUpdateApplication() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); Application addApp = createApplication(APPNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(addApp.getId(), TEAMNAME)).thenReturn(addApp); when(applicationRepository.findOne(addApp.getId())).thenReturn(addApp); when(applicationRepository.save(addApp)).thenReturn(addApp); ResponseEntity<Object> response = appController.updateApplication(req, addApp.getId(), addApp); Application getApp = (Application) response.getBody(); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(TEAMNAME, getApp.getTeamName()); assertEquals(APPNAME, getApp.getApplicationName()); }
|
@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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, 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 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") public ResponseEntity<Object> updateApplication(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Application toModifyApplication) { logger.debug("Updating Application with ID: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyApplication.getTeamName()) && !toModifyApplication.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be changed only by the owning Team -->" + toModifyApplication.getTeamName() + "<--"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } Application currentApplication = applicationService.findOneForTeam(id, teamName); if (currentApplication == null) { final String error = "Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyApplication.setId(id); toModifyApplication.setTeamName(teamName); applicationService.update(toModifyApplication); return new ResponseEntity<>(toModifyApplication, 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); }
|
@Test public void testDeleteApplicationErrCndtn() { Application addApp = createApplication(APPNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(addApp.getId(), OTHERTEAM)).thenReturn(addApp); MessageWrapper apiError = (MessageWrapper) appController.deleteApplication(req, addApp.getId()).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("Application can be deleted only by the owning Team " + addApp.getTeamName(), apiError.getStatusMessage()); when(applicationRepository.findOneForTeam(addApp.getId(), TEAMNAME)).thenReturn(null); setSecuirtyContext(TEAMNAME, USERNAME); teamUser.setTeamName(TEAMNAME); apiError = (MessageWrapper) appController.deleteApplication(req, addApp.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Unable to delete. Application with id " + addApp.getId() + " not found", apiError.getStatusMessage()); }
|
@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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(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 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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(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); }
|
@Test public void testdeleteApplication() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); Application addApp = createApplication(APPNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(applicationRepository.findOneForTeam(addApp.getId(), TEAMNAME)).thenReturn(addApp); when(applicationRepository.findOne(addApp.getId())).thenReturn(addApp); when(applicationRepository.save(addApp)).thenReturn(addApp); ResponseEntity<Object> response = appController.deleteApplication(req, addApp.getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(applicationRepository, times(1)).delete(addApp); }
|
@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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(HttpStatus.OK); } }
|
ApplicationRestController { @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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(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 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") public ResponseEntity<Object> deleteApplication(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Deleting Application with id: " + id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Application application = applicationService.findOneForTeam(id, teamName); if (application == null) { final String error = "Unable to delete. Application with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (!AppUtil.getSuperUser().equalsIgnoreCase(application.getTeamName()) && !application.getTeamName().equalsIgnoreCase(teamName)) { final String error = "Application can be deleted only by the owning Team " + application.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } applicationService.delete(application); return new ResponseEntity<>(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); }
|
@Test public void testListScenarios() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); when(scenarioRepository.findAll()).thenReturn(sceList); List<Scenario> scenarioList = (List<Scenario>) scenarioController.listScenarios().getBody(); assertEquals(1, scenarioList.size()); assertEquals(SCENARIONAME, scenarioList.get(0).getName()); assertEquals(TEAMNAME, scenarioList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testListScenariosErrCond() { List<Scenario> sceList = new ArrayList<>(); when(scenarioRepository.findAll()).thenReturn(sceList); ResponseEntity<List<Scenario>> response = scenarioController.listScenarios(); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
|
@ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) public ResponseEntity<List<Scenario>> listScenarios() { List<Scenario> scenarios = Lists.newArrayList(scenarioService.findAll()); if (scenarios.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testListAllScenarios() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findAllForTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(scePage); List<Scenario> scenarioList = (List<Scenario>) scenarioController.listAllScenarios(req).getBody(); assertEquals(1, scenarioList.size()); assertEquals(SCENARIONAME, scenarioList.get(0).getName()); assertEquals(TEAMNAME, scenarioList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(monkeyStrategy); MonkeyStrategy getMonkeyStrategy = (MonkeyStrategy) monkeyStrategyController .getMonkeyStrategy(req, monkeyStrategy.getId()).getBody(); assertEquals(TESTMSID, getMonkeyStrategy.getId()); assertEquals(MONKEYSTRATEGYNAME, getMonkeyStrategy.getMonkeyStrategyName()); assertEquals(TEAMNAME, getMonkeyStrategy.getTeamName()); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); getMonkeyStrategy = (MonkeyStrategy) monkeyStrategyController.getMonkeyStrategy(req, monkeyStrategy.getId()) .getBody(); assertEquals(TESTMSID, getMonkeyStrategy.getId()); assertEquals(MONKEYSTRATEGYNAME, getMonkeyStrategy.getMonkeyStrategyName()); assertEquals(TEAMNAME, getMonkeyStrategy.getTeamName()); }
|
@ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testListAllScenariosErrCond() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); Page<Scenario> scePage = new PageImpl<>(sceList); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findAllForTeamName(TEAMNAME, new PageRequest(0, 9999))).thenReturn(scePage); ResponseEntity<List<Scenario>> response = scenarioController.listAllScenarios(req); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); }
|
@ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> events = Lists.newArrayList(scenarioService.findAllByTeamName(teamName)); if (events.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(events, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(scenarioRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(scenarioRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); String appCount = (String) scenarioController.countByTeamName(req).getBody(); assertEquals("1", appCount); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); appCount = (String) scenarioController.countByTeamName(req).getBody(); assertEquals("2", appCount); }
|
@ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = scenarioService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = scenarioService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = scenarioService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = scenarioService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = scenarioService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenario() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(sce.getId())).thenReturn(sce); Scenario scenario = (Scenario) scenarioController.getScenario(sce.getId()).getBody(); assertEquals(TESTSCENARIOID, scenario.getId()); assertEquals(SCENARIONAME, scenario.getName()); assertEquals(TEAMNAME, scenario.getTeamName()); }
|
@ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenarioErrCndtn() { String sceID = "notExistSCEID"; when(scenarioRepository.findOne(sceID)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) scenarioController.getScenario(sceID).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario not found with id " + sceID, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenario(@PathVariable("id") String id) { Scenario scenario = scenarioService.findOne(id); if (scenario == null) { String error = "Scenario not found with id " + id; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenarioByName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(sce.getName(), sce.getTeamName())).thenReturn(sce); Scenario scenario = (Scenario) scenarioController.getScenarioByName(req, sce.getName()).getBody(); assertEquals(TESTSCENARIOID, scenario.getId()); assertEquals(SCENARIONAME, scenario.getName()); assertEquals(TEAMNAME, scenario.getTeamName()); }
|
@ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenarioByNameErrCndtn() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(sce.getName(), sce.getTeamName())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) scenarioController.getScenarioByName(req, sce.getName()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario not found with name " + sce.getName(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Scenario scenario = scenarioService.findByScenarioNameByTeamName(name, teamName); if (scenario == null) { String error = "Scenario not found with name " + name; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testListAllScenariosByApplicationName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findByApplicationNameAndTeamName(sce.getApplicationName(), sce.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); @SuppressWarnings("unchecked") List<Scenario> scenarioList = (List<Scenario>) scenarioController .listAllScenariosByApplicationName(req, sce.getApplicationName()).getBody(); assertEquals(1, scenarioList.size()); assertEquals(SCENARIONAME, scenarioList.get(0).getName()); assertEquals(TEAMNAME, scenarioList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testListAllScenariosByApplicationNameErrCndtn() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findByApplicationNameAndTeamName(sce.getApplicationName(), sce.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); MessageWrapper apiError = (MessageWrapper) scenarioController .listAllScenariosByApplicationName(req, sce.getApplicationName()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("No Scenarios found under Application " + sce.getApplicationName(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarios = Lists .newArrayList(scenarioService.findByApplicationNameByTeamName(applicationName, teamName)); if (scenarios.isEmpty()) { String error = "No Scenarios found under Application " + applicationName; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarios, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenarioListByName() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(sce); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenariosByNameAndTeamName(sce.getName(), sce.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); @SuppressWarnings("unchecked") List<Scenario> scenarioList = (List<Scenario>) scenarioController.getScenarioListByName(req, sce.getName()) .getBody(); assertEquals(1, scenarioList.size()); assertEquals(SCENARIONAME, scenarioList.get(0).getName()); assertEquals(TEAMNAME, scenarioList.get(0).getTeamName()); }
|
@ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetScenarioListByNameErrCndtn() { Scenario sce = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenariosByNameAndTeamName(sce.getName(), sce.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); MessageWrapper apiError = (MessageWrapper) scenarioController.getScenarioListByName(req, sce.getName()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario with name " + sce.getName() + NOTFOUND, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Page<Scenario> scenarioPage = scenarioService.findScenarioListByScenarioNameByTeamName(name, teamName, new PageRequest(0, 9999)); List<Scenario> scenarioList = scenarioPage.getContent(); if (scenarioList == null || scenarioList.isEmpty()) { String error = "Scenario with name " + name + NOTFOUND; logger.debug(error); MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(scenarioList, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetMonkeyStrategyErrCndtn() { String msID = "notExistMSID"; setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findOne(msID)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController.getMonkeyStrategy(req, msID).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("MonkeyStrategy not found for id " + msID, apiError.getStatusMessage()); teamUser.setTeamName(OTHERTEAM); setSecuirtyContext(OTHERTEAM, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(monkeyStrategy); apiError = (MessageWrapper) monkeyStrategyController.getMonkeyStrategy(req, monkeyStrategy.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("MonkeyStrategy not found for id " + monkeyStrategy.getId(), apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id) { logger.debug("Fetching monkeyStrategy with id : %s ", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (monkeyStrategy == null) { final String error = "MonkeyStrategy not found for id " + id; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void testaddScenarioErrCndtn() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(scenario); MessageWrapper apiError = (MessageWrapper) scenarioController.addScenario(req, scenario, ucBuilder).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("A scenario with name " + scenario.getName() + " already exist", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testAddScenario() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(null); ResponseEntity<Object> response = scenarioController.addScenario(req, scenario, ucBuilder); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
|
@ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) public ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder) { logger.debug("Creating scenario with name ->%s, application name ->%s", scenario.getName(), scenario.getApplicationName()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { final String error = SCENARIO + scenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenario.setTeamName(teamName.trim()); scenarioService.save(scenario, teamName); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/scenarios/{id}").buildAndExpand(scenario.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testBulkAddScenarioErrCndtn() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(scenario); MessageWrapper apiError = (MessageWrapper) scenarioController.bulkaddScenario(req, sceAdapter).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("Scenarios with same name are already exist for selected application and environment.", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testBulkaddScenario() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(null); ResponseEntity<Object> response = scenarioController.bulkaddScenario(req, sceAdapter); assertEquals(HttpStatus.CREATED, response.getStatusCode()); verify(scenarioRepository, times(1)).save(sceList); }
|
@ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> toBeInertScenarios = new ArrayList<>(); for (Scenario scenario : scenarioAdapter.getScenarios()) { scenario.setTeamName(teamName); if (scenarioService.isScenarioExistForTeamName(scenario, teamName)) { logger.debug(SCENARIO + scenario.getName() + " already exists."); } else { toBeInertScenarios.add(scenario); } } if (toBeInertScenarios.isEmpty()) { final String error = "Scenarios with same name are already exist for selected application and environment."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } else { scenarioService.save(toBeInertScenarios, teamName); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.CREATED); } } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testUpdateScenarioErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) scenarioController.updateScenario(req, scenario.getId(), scenario) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario with id " + scenario.getId() + NOTFOUND, apiError.getStatusMessage()); when(scenarioRepository.findOne(scenario.getId())).thenReturn(scenario); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(scenario); apiError = (MessageWrapper) scenarioController.updateScenario(req, scenario.getId(), scenario).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("A scenario with name " + scenario.getName() + " already exist", apiError.getStatusMessage()); Scenario scenario1 = createScenario(SCENARIONAME, "TEST1"); when(scenarioRepository.findOne(scenario.getId())).thenReturn(scenario1); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(null); apiError = (MessageWrapper) scenarioController.updateScenario(req, scenario.getId(), scenario).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario is not owned by Team " + scenario.getTeamName(), apiError.getStatusMessage()); scenario = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(scenario); when(scenarioRepository.save(scenario)).thenReturn(null); apiError = (MessageWrapper) scenarioController.updateScenario(req, scenario.getId(), scenario).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Scenario with id " + scenario.getId() + " is not updated", apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testUpdateScenario() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findOne(scenario.getId())).thenReturn(scenario); when(scenarioRepository.findScenarioByNameAndTeamName(scenario.getName(), scenario.getTeamName())) .thenReturn(null); when(scenarioRepository.save(scenario)).thenReturn(scenario); ResponseEntity<Object> response = scenarioController.updateScenario(req, scenario.getId(), scenario); assertEquals(HttpStatus.OK, response.getStatusCode()); }
|
@ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario) { logger.debug("Updating Scenario with ID: " + id); Scenario currentScenario = scenarioService.findOne(id); if (currentScenario == null) { final String error = "Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); toModifyScenario.setTeamName(currentScenario.getTeamName()); if (scenarioService.isScenarioExistForTeamName(toModifyScenario, teamName)) { final String error = SCENARIO + toModifyScenario.getName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (toModifyScenario.getTeamName() == null || !toModifyScenario.getTeamName().trim().equalsIgnoreCase(teamName)) { final String error = "Scenario is not owned by Team " + toModifyScenario.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyScenario.setId(id); Scenario modifiedScenario = scenarioService.update(toModifyScenario, teamName); if (modifiedScenario == null) { final String error = "Scenario with id " + id + " is not updated"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(modifiedScenario, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testDeleteScenarioErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) scenarioController.deleteScenario(scenario.getId()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Unable to delete. Scenario with id " + scenario.getId() + NOTFOUND, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testDeleteScenario() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); when(scenarioRepository.findOne(scenario.getId())).thenReturn(scenario); ResponseEntity<Object> response = scenarioController.deleteScenario(scenario.getId()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(scenarioRepository, times(1)).delete(scenario); }
|
@ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenario(@PathVariable("id") String id) { logger.debug("Deleting Scenario with id " + id); Scenario scenario = scenarioService.findOne(id); if (scenario == null) { final String error = "Unable to delete. Scenario with id " + id + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testDeleteScenarioForApplicationErrCndtn() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); List<Scenario> sceList = new ArrayList<>(); Page<Scenario> scePage = new PageImpl<>(sceList); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findByApplicationNameAndTeamName(scenario.getApplicationName(), scenario.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); MessageWrapper apiError = (MessageWrapper) scenarioController .deleteScenarioForApplication(req, scenario.getApplicationName()).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Unable to delete. Scenario for application " + scenario.getApplicationName() + NOTFOUND, apiError.getStatusMessage()); }
|
@ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testDeleteScenarioForApplication() { Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); List<Scenario> sceList = new ArrayList<>(); sceList.add(scenario); Page<Scenario> scePage = new PageImpl<>(sceList); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(scenarioRepository.findByApplicationNameAndTeamName(scenario.getApplicationName(), scenario.getTeamName(), new PageRequest(0, 9999))).thenReturn(scePage); ResponseEntity<Object> response = scenarioController.deleteScenarioForApplication(req, scenario.getApplicationName()); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(scenarioRepository, times(1)).delete(scenario); }
|
@ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
ScenarioRestController { @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName) { logger.debug("Deleting all Scenarios for application " + applicationName); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); List<Scenario> scenarioList = scenarioService.findByApplicationNameByTeamName(applicationName, teamName); if (scenarioList == null || scenarioList.isEmpty()) { final String error = "Unable to delete. Scenario for application " + applicationName + NOTFOUND; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } for (Scenario scenario : scenarioList) { scenarioService.delete(scenario); } return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario 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/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario,
UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request,
@PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario 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/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario 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/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @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/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request,
@RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request,
@RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request,
@RequestBody ScenarioAdapter scenarioAdapter); }
|
@Test public void testGetMonkeyStrategyByName() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyStrategyNameAndTeamName(monkeyStrategy.getMonkeyStrategyName(), TEAMNAME)).thenReturn(monkeyStrategy); MonkeyStrategy getMonkeyStrategy = (MonkeyStrategy) monkeyStrategyController .getMonkeyStrategyByName(req, monkeyStrategy.getMonkeyStrategyName()).getBody(); assertEquals(MONKEYSTRATEGYNAME, getMonkeyStrategy.getMonkeyStrategyName()); assertEquals(TEAMNAME, getMonkeyStrategy.getTeamName()); }
|
@ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + 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<>(monkeyStrategy, HttpStatus.OK); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + 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<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + 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<>(monkeyStrategy, HttpStatus.OK); } }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + 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<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + 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<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @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/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request,
@PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request,
@PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @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/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request,
@PathVariable("applicationname") String applicationname,
@PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy 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/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request,
@RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id,
@RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
|
@Test public void shouldShowDifferentLifeCyclePhases() throws Exception { Customer customer = new Customer("John", "Smith", "[email protected]", "1234565"); assertFalse(em.contains(customer)); System.out.println("\nPERSIST"); tx.begin(); em.persist(customer); tx.commit(); assertTrue(em.contains(customer), "should be in the persistence context after persisting"); System.out.println("\nFIND"); em.clear(); assertFalse(em.contains(customer), "should not be in the persistence context after clearing"); customer = em.find(Customer.class, customer.getId()); assertTrue(em.contains(customer), "should be in the persistence context after finding"); System.out.println("\nDETACH"); em.detach(customer); assertFalse(em.contains(customer), "should not be in the persistence context after detaching"); customer = em.find(Customer.class, customer.getId()); assertTrue(em.contains(customer), "should be in the persistence context after finding"); System.out.println("\nREFRESH"); customer.setEmail("[email protected]"); tx.begin(); em.refresh(customer); tx.commit(); assertTrue(em.contains(customer), "should be in the persistence context after refreshing"); System.out.println("\nSET"); tx.begin(); customer.setFirstName("new first name"); customer.setFirstName("new last name"); tx.commit(); System.out.println("\nMERGE"); em.clear(); assertFalse(em.contains(customer), "should not be in the persistence context after clearing"); customer.setEmail("[email protected]"); tx.begin(); customer = em.merge(customer); tx.commit(); assertTrue(em.contains(customer), "should be in the persistence context after merging"); System.out.println("\nREMOVE"); tx.begin(); em.remove(customer); tx.commit(); assertFalse(em.contains(customer), "should not be in the persistence context after removing"); }
|
public void setEmail(String email) { this.email = email; }
|
Customer extends Person { public void setEmail(String email) { this.email = email; } }
|
Customer extends Person { public void setEmail(String email) { this.email = email; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); }
|
Customer extends Person { public void setEmail(String email) { this.email = email; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); String getEmail(); void setEmail(String email); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); Integer getAge(); void setAge(Integer age); }
|
Customer extends Person { public void setEmail(String email) { this.email = email; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber); String getEmail(); void setEmail(String email); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); Integer getAge(); void setAge(Integer age); }
|
@Test public void shouldCreateSeveralItems() throws Exception { Item item = new Item("Junk", 52.50f, "A piece of junk"); CD cd01 = new CD("St Pepper", 12.80f, "Beatles master piece", "Apple", 1, 53.32f, "Pop/Rock"); CD cd02 = new CD("Love SUpreme", 20f, "John Coltrane love moment", "Blue Note", 2, 87.45f, "Jazz"); Book book01 = new Book("H2G2", 21f, "Best IT book", "123-456-789", "Pinguin", 321, false); Book book02 = new Book("The Robots of Dawn", 37.5f, "Robots, again and again", "0-553-29949-2 ", "Foundation", 264, true); tx.begin(); em.persist(item); em.persist(cd01); em.persist(cd02); em.persist(book01); em.persist(book02); tx.commit(); assertNotNull(item.getId(), "Item Id should not be null"); assertNotNull(cd01.getId(), "CD1 Id should not be null"); assertNotNull(cd02.getId(), "CD2 Id should not be null"); assertNotNull(book01.getId(), "Book1 Id should not be null"); assertNotNull(book02.getId(), "Book2 Id should not be null"); }
|
public Long getId() { return id; }
|
Item { public Long getId() { return id; } }
|
Item { public Long getId() { return id; } Item(); Item(String title, Float price, String description); }
|
Item { public Long getId() { return id; } Item(); Item(String title, Float price, String description); Long getId(); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); }
|
Item { public Long getId() { return id; } Item(); Item(String title, Float price, String description); Long getId(); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); }
|
@Test public void shouldCreateACreditCard() throws Exception { CreditCard creditCard = new CreditCard("123412341234", "12/12", 1253, AMERICAN_EXPRESS); tx.begin(); em.persist(creditCard); tx.commit(); assertNotNull(creditCard.getNumber(), "Id should not be null"); String dbCreditCardType = (String) em.createNativeQuery("select creditCardType from CreditCard where number = '123412341234'").getSingleResult(); assertEquals("A", dbCreditCardType, "Should be A for American Express"); }
|
public String getNumber() { return number; }
|
CreditCard { public String getNumber() { return number; } }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); String getNumber(); void setNumber(String number); String getExpiryDate(); void setExpiryDate(String expiryDate); Integer getControlNumber(); void setControlNumber(Integer controlNumber); CreditCardType getType(); void setType(CreditCardType creditCardType); }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); String getNumber(); void setNumber(String number); String getExpiryDate(); void setExpiryDate(String expiryDate); Integer getControlNumber(); void setControlNumber(Integer controlNumber); CreditCardType getType(); void setType(CreditCardType creditCardType); }
|
@Test public void shouldCreateAnAddress() throws Exception { Address address = new Address(getRandomId(), "65B Ritherdon Rd", "At James place", "London", "LDN", "7QE554", "UK"); tx.begin(); em.persist(address); tx.commit(); assertNotNull(address.getId(), "Id should not be null"); }
|
public Long getId() { return id; }
|
Address { public Long getId() { return id; } }
|
Address { public Long getId() { return id; } Address(); Address(Long id, String street1, String street2, String city, String state, String zipcode, String country); }
|
Address { public Long getId() { return id; } Address(); Address(Long id, String street1, String street2, String city, String state, String zipcode, String country); Long getId(); void setId(Long id); String getStreet1(); void setStreet1(String street1); String getStreet2(); void setStreet2(String street2); String getCity(); void setCity(String city); String getState(); void setState(String state); String getZipcode(); void setZipcode(String zipcode); String getCountry(); void setCountry(String country); }
|
Address { public Long getId() { return id; } Address(); Address(Long id, String street1, String street2, String city, String state, String zipcode, String country); Long getId(); void setId(Long id); String getStreet1(); void setStreet1(String street1); String getStreet2(); void setStreet2(String street2); String getCity(); void setCity(String city); String getState(); void setState(String state); String getZipcode(); void setZipcode(String zipcode); String getCountry(); void setCountry(String country); }
|
@Test public void shouldCreateABook() throws Exception { Book book = new Book(getRandomId(), "The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false); tx.begin(); em.persist(book); tx.commit(); assertNotNull(book.getId(), "Id should not be null"); }
|
public Long getId() { return id; }
|
Book { public Long getId() { return id; } }
|
Book { public Long getId() { return id; } Book(); Book(Long id, String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); }
|
Book { public Long getId() { return id; } Book(); Book(Long id, String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); String getIsbn(); void setIsbn(String isbn); Integer getNbOfPages(); void setNbOfPages(Integer nbOfPages); Boolean getIllustrations(); void setIllustrations(Boolean illustrations); }
|
Book { public Long getId() { return id; } Book(); Book(Long id, String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); String getIsbn(); void setIsbn(String isbn); Integer getNbOfPages(); void setNbOfPages(Integer nbOfPages); Boolean getIllustrations(); void setIllustrations(Boolean illustrations); }
|
@Test public void shouldCreateABook() throws Exception { Book book = new Book("The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false); tx.begin(); em.persist(book); tx.commit(); assertNotNull(book.getId(), "Id should not be null"); }
|
public Long getId() { return id; }
|
Book { public Long getId() { return id; } }
|
Book { public Long getId() { return id; } Book(); Book(String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); }
|
Book { public Long getId() { return id; } Book(); Book(String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); String getIsbn(); void setIsbn(String isbn); Integer getNbOfPages(); void setNbOfPages(Integer nbOfPages); Boolean getIllustrations(); void setIllustrations(Boolean illustrations); }
|
Book { public Long getId() { return id; } Book(); Book(String title, Float price, String description, String isbn, Integer nbOfPages, Boolean illustrations); Long getId(); void setId(Long id); String getTitle(); void setTitle(String title); Float getPrice(); void setPrice(Float price); String getDescription(); void setDescription(String description); String getIsbn(); void setIsbn(String isbn); Integer getNbOfPages(); void setNbOfPages(Integer nbOfPages); Boolean getIllustrations(); void setIllustrations(Boolean illustrations); }
|
@Test public void shouldCreateANews() throws Exception { News news = new News(new NewsId("Richard Wright has died", "EN"), "The keyboard of Pink Floyd has died today"); tx.begin(); em.persist(news); tx.commit(); news = em.find(News.class, new NewsId("Richard Wright has died", "EN")); assertEquals("The keyboard of Pink Floyd has died today", news.getContent()); }
|
public String getContent() { return content; }
|
News { public String getContent() { return content; } }
|
News { public String getContent() { return content; } News(); News(NewsId id, String content); }
|
News { public String getContent() { return content; } News(); News(NewsId id, String content); NewsId getId(); void setId(NewsId id); String getContent(); void setContent(String content); }
|
News { public String getContent() { return content; } News(); News(NewsId id, String content); NewsId getId(); void setId(NewsId id); String getContent(); void setContent(String content); }
|
@Test public void shouldCreateACreditCard() throws Exception { CreditCard creditCard = new CreditCard("123412341234", "12/12", 1253, CreditCardType.AMERICAN_EXPRESS); tx.begin(); em.persist(creditCard); tx.commit(); assertNotNull(creditCard.getNumber(), "Id should not be null"); }
|
public String getNumber() { return number; }
|
CreditCard { public String getNumber() { return number; } }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); String getNumber(); void setNumber(String number); String getExpiryDate(); void setExpiryDate(String expiryDate); Integer getControlNumber(); void setControlNumber(Integer controlNumber); CreditCardType getType(); void setType(CreditCardType creditCardType); }
|
CreditCard { public String getNumber() { return number; } CreditCard(); CreditCard(String number, String expiryDate, Integer controlNumber, CreditCardType creditCardType); String getNumber(); void setNumber(String number); String getExpiryDate(); void setExpiryDate(String expiryDate); Integer getControlNumber(); void setControlNumber(Integer controlNumber); CreditCardType getType(); void setType(CreditCardType creditCardType); }
|
@Test @Transactional public void createAddress() throws Exception { mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string(ALL_ADDRESSES)); Address address = new Address().street1("233 Spring Street").city("New York").state("NY").zipcode("12345").country("USA"); mockAddressEndpoint.perform(post("/addresses") .contentType("application/json") .content(convertObjectToJsonBytes(address))) .andExpect(status().isOk()); mockAddressEndpoint.perform(get("/addresses/count")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(content().string("8")); }
|
@PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); }
|
AddressEndpoint { @PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); } }
|
AddressEndpoint { @PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); } AddressEndpoint(AddressRepository addressRepository); }
|
AddressEndpoint { @PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMapping(value = "/addresses/count") Long countAll(); @GetMapping(value = "/addresses/country/{country}") List<Address> getAddressesByCountry(@PathVariable String country); @GetMapping(value = "/addresses/like/{zip}") List<Address> getAddressesLikeZip(@PathVariable String zip); }
|
AddressEndpoint { @PostMapping("/addresses") public Address createAddress(@RequestBody Address address) { return addressRepository.save(address); } AddressEndpoint(AddressRepository addressRepository); @PostMapping("/addresses") Address createAddress(@RequestBody Address address); @GetMapping(value = "/addresses/count") Long countAll(); @GetMapping(value = "/addresses/country/{country}") List<Address> getAddressesByCountry(@PathVariable String country); @GetMapping(value = "/addresses/like/{zip}") List<Address> getAddressesLikeZip(@PathVariable String zip); }
|
@Test public void shoulCreateACustomer() throws Exception { Customer customer = new Customer("John", "Smith", "[email protected]", "1234565", new Date(), new Date()); tx.begin(); em.persist(customer); tx.commit(); Assertions.assertNotNull(customer.getId(), "Id should not be null"); }
|
public Long getId() { return id; }
|
Customer { public Long getId() { return id; } }
|
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber, Date dateOfBirth, Date creationDate); }
|
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber, Date dateOfBirth, Date creationDate); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); Date getDateOfBirth(); void setDateOfBirth(Date dateOfBirth); Date getCreationDate(); void setCreationDate(Date creationDate); }
|
Customer { public Long getId() { return id; } Customer(); Customer(String firstName, String lastName, String email, String phoneNumber, Date dateOfBirth, Date creationDate); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); String getPhoneNumber(); void setPhoneNumber(String phoneNumber); Date getDateOfBirth(); void setDateOfBirth(Date dateOfBirth); Date getCreationDate(); void setCreationDate(Date creationDate); }
|
@Test void shouldCreateABook() { BookService bookService = new BookService(); bookService.createBook(); }
|
public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.persist(book); tx.commit(); em.close(); emf.close(); }
|
BookService { public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.persist(book); tx.commit(); em.close(); emf.close(); } }
|
BookService { public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.persist(book); tx.commit(); em.close(); emf.close(); } }
|
BookService { public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.persist(book); tx.commit(); em.close(); emf.close(); } void createBook(); }
|
BookService { public void createBook() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("cdbookstorePU"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); Book book = new Book().title("H2G2").price(12.5F).isbn("1-84023-742-2").nbOfPages(354); tx.begin(); em.persist(book); tx.commit(); em.close(); emf.close(); } void createBook(); }
|
@Test public void shouldPersistWithFlush() throws Exception { Customer customer = new Customer("Anthony", "Balla", "[email protected]"); Address address = new Address("Ritherdon Rd", "London", "8QE", "UK"); customer.setAddress(address); assertThrows(IllegalStateException.class, () -> { tx.begin(); em.persist(customer); em.flush(); em.persist(address); tx.commit(); }); }
|
public void setAddress(Address address) { this.address = address; }
|
Customer { public void setAddress(Address address) { this.address = address; } }
|
Customer { public void setAddress(Address address) { this.address = address; } Customer(); Customer(String firstName, String lastName, String email); }
|
Customer { public void setAddress(Address address) { this.address = address; } Customer(); Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); Address getAddress(); void setAddress(Address address); }
|
Customer { public void setAddress(Address address) { this.address = address; } Customer(); Customer(String firstName, String lastName, String email); Long getId(); String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); String getEmail(); void setEmail(String email); Address getAddress(); void setAddress(Address address); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.