@Test public void shouldReturnErrorMessageWhileGettingAScheduleForIdThatDoesNotExist() { doThrow(new DataException("Schedule not found")).when(processingScheduleService).get(1L); ResponseEntity<OpenLmisResponse> response = processingScheduleController.get(1L); verify(processingScheduleService).get(1L); assertThat(response.getStatusCode(), is(HttpStatus.NOT_FOUND)); assertThat(response.getBody().getErrorMsg(), is("Schedule not found")); }
@RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { try { ProcessingSchedule processingSchedule = processingScheduleService.get(id); return OpenLmisResponse.response(SCHEDULE, processingSchedule); } catch (DataException e) { return error(e, HttpStatus.NOT_FOUND); } }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { try { ProcessingSchedule processingSchedule = processingScheduleService.get(id); return OpenLmisResponse.response(SCHEDULE, processingSchedule); } catch (DataException e) { return error(e, HttpStatus.NOT_FOUND); } } }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { try { ProcessingSchedule processingSchedule = processingScheduleService.get(id); return OpenLmisResponse.response(SCHEDULE, processingSchedule); } catch (DataException e) { return error(e, HttpStatus.NOT_FOUND); } }  }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { try { ProcessingSchedule processingSchedule = processingScheduleService.get(id); return OpenLmisResponse.response(SCHEDULE, processingSchedule); } catch (DataException e) { return error(e, HttpStatus.NOT_FOUND); } }  @RequestMapping(value = "/schedules", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE, MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request); @RequestMapping(value = "/schedules/{id}", method = RequestMethod.PUT, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> update(@RequestBody ProcessingSchedule processingSchedule, @PathVariable("id") Long id, HttpServletRequest request); @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { try { ProcessingSchedule processingSchedule = processingScheduleService.get(id); return OpenLmisResponse.response(SCHEDULE, processingSchedule); } catch (DataException e) { return error(e, HttpStatus.NOT_FOUND); } }  @RequestMapping(value = "/schedules", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE, MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request); @RequestMapping(value = "/schedules/{id}", method = RequestMethod.PUT, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> update(@RequestBody ProcessingSchedule processingSchedule, @PathVariable("id") Long id, HttpServletRequest request); @RequestMapping(value = "/schedules/{id}", method = RequestMethod.GET, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); static final String SCHEDULES; static final String SCHEDULE; }