@Test public void shouldReturnErrorResponseWhenTryingToSaveAScheduleWithNoCodeSet() throws Exception { ProcessingSchedule processingSchedule = new ProcessingSchedule(); doThrow(new DataException("Schedule can not be saved without its code.")).when(processingScheduleService).save(processingSchedule); ResponseEntity<OpenLmisResponse> response = processingScheduleController.create(processingSchedule, httpServletRequest); verify(processingScheduleService).save(processingSchedule); assertThat(response.getStatusCode(), is(HttpStatus.BAD_REQUEST)); assertThat(response.getBody().getErrorMsg(), is("Schedule can not be saved without its code.")); }
@RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request) { processingSchedule.setCreatedBy(loggedInUserId(request)); processingSchedule.setModifiedBy(loggedInUserId(request)); return saveSchedule(processingSchedule, true); }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request) { processingSchedule.setCreatedBy(loggedInUserId(request)); processingSchedule.setModifiedBy(loggedInUserId(request)); return saveSchedule(processingSchedule, true); } }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request) { processingSchedule.setCreatedBy(loggedInUserId(request)); processingSchedule.setModifiedBy(loggedInUserId(request)); return saveSchedule(processingSchedule, true); }  }
ProcessingScheduleController extends BaseController { @RequestMapping(value = "/schedules", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request) { processingSchedule.setCreatedBy(loggedInUserId(request)); processingSchedule.setModifiedBy(loggedInUserId(request)); return saveSchedule(processingSchedule, true); }  @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", method = RequestMethod.POST, headers = "Accept=application/json") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> create(@RequestBody ProcessingSchedule processingSchedule, HttpServletRequest request) { processingSchedule.setCreatedBy(loggedInUserId(request)); processingSchedule.setModifiedBy(loggedInUserId(request)); return saveSchedule(processingSchedule, true); }  @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; }