@Test public void shouldDeletePeriodIfStartDateGreaterThanCurrentDate() { when(messageService.message("message.period.deleted.success")).thenReturn("Period deleted successfully"); ResponseEntity<OpenLmisResponse> responseEntity = controller.delete(PROCESSING_PERIOD_ID); verify(service).deletePeriod(PROCESSING_PERIOD_ID); assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK)); assertThat(responseEntity.getBody().getSuccessMsg(), is("Period deleted successfully")); }
@RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id) { try { processingScheduleService.deletePeriod(id); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } return success(messageService.message("message.period.deleted.success")); }
ProcessingPeriodController extends BaseController { @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id) { try { processingScheduleService.deletePeriod(id); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } return success(messageService.message("message.period.deleted.success")); } }
ProcessingPeriodController extends BaseController { @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id) { try { processingScheduleService.deletePeriod(id); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } return success(messageService.message("message.period.deleted.success")); }  }
ProcessingPeriodController extends BaseController { @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id) { try { processingScheduleService.deletePeriod(id); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } return success(messageService.message("message.period.deleted.success")); }  @RequestMapping(value = "/schedules/{scheduleId}/periods", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> getAll(@PathVariable("scheduleId") Long scheduleId); @RequestMapping(value = "/schedules/{scheduleId}/periods", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> save(@PathVariable("scheduleId") Long scheduleId, @RequestBody ProcessingPeriod processingPeriod, HttpServletRequest request); @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id); @RequestMapping(value = "/periods/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); }
ProcessingPeriodController extends BaseController { @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id) { try { processingScheduleService.deletePeriod(id); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } return success(messageService.message("message.period.deleted.success")); }  @RequestMapping(value = "/schedules/{scheduleId}/periods", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> getAll(@PathVariable("scheduleId") Long scheduleId); @RequestMapping(value = "/schedules/{scheduleId}/periods", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> save(@PathVariable("scheduleId") Long scheduleId, @RequestBody ProcessingPeriod processingPeriod, HttpServletRequest request); @RequestMapping(value = "/periods/{id}", method = DELETE, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") ResponseEntity<OpenLmisResponse> delete(@PathVariable("id") Long id); @RequestMapping(value = "/periods/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); static final String PERIODS; static final String NEXT_START_DATE; }