@Test public void shouldRemove() throws Exception { doNothing().when(donorService).removeDonor(20L); ResponseEntity<OpenLmisResponse> response = controller.remove(20L, request); assertThat(response.getBody().getSuccessMsg(), is(notNullValue())); }
@RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") public ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> successResponse; try { donorService.removeDonor(donorId); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } successResponse = success(String.format("Donor has been successfully removed")); return successResponse; }
DonorController extends BaseController { @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") public ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> successResponse; try { donorService.removeDonor(donorId); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } successResponse = success(String.format("Donor has been successfully removed")); return successResponse; } }
DonorController extends BaseController { @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") public ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> successResponse; try { donorService.removeDonor(donorId); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } successResponse = success(String.format("Donor has been successfully removed")); return successResponse; }  }
DonorController extends BaseController { @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") public ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> successResponse; try { donorService.removeDonor(donorId); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } successResponse = success(String.format("Donor has been successfully removed")); return successResponse; }  @RequestMapping(value="list",method= GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR, MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value="insert.json",method=POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> save(@RequestBody Donor donor, HttpServletRequest request); @RequestMapping(value="getDetails/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> getDetailsForDonor(@PathVariable(value="id") Long id); @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request); }
DonorController extends BaseController { @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") public ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request){ ResponseEntity<OpenLmisResponse> successResponse; try { donorService.removeDonor(donorId); } catch (DataException e) { return error(e, HttpStatus.BAD_REQUEST); } successResponse = success(String.format("Donor has been successfully removed")); return successResponse; }  @RequestMapping(value="list",method= GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR, MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value="insert.json",method=POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> save(@RequestBody Donor donor, HttpServletRequest request); @RequestMapping(value="getDetails/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> getDetailsForDonor(@PathVariable(value="id") Long id); @RequestMapping(value="remove/{id}",method = GET,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DONOR')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="id") Long donorId, HttpServletRequest request); static final String DONOR; static final String DONORS; }