@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);  }