@Test public void shouldSave() throws Exception { EquipmentType type = new EquipmentType(); type.setName("Test"); controller.save(type, httpServletRequest); verify(service).save(type); }
@RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request){ try { Long userId = loggedInUserId(request); type.setCreatedBy(userId); type.setModifiedBy(userId); service.save(type); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response(STATUS,"success"); }
EquipmentTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request){ try { Long userId = loggedInUserId(request); type.setCreatedBy(userId); type.setModifiedBy(userId); service.save(type); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response(STATUS,"success"); } }
EquipmentTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request){ try { Long userId = loggedInUserId(request); type.setCreatedBy(userId); type.setModifiedBy(userId); service.save(type); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response(STATUS,"success"); }  }
EquipmentTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request){ try { Long userId = loggedInUserId(request); type.setCreatedBy(userId); type.setModifiedBy(userId); service.save(type); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response(STATUS,"success"); }  @RequestMapping(method = GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = GET, value = "id") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')" + " or @permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getById( @RequestParam("id") Long id); @RequestMapping(method = GET, value = "operational-status") ResponseEntity<OpenLmisResponse> getAllStatuses( ); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request); }
EquipmentTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request){ try { Long userId = loggedInUserId(request); type.setCreatedBy(userId); type.setModifiedBy(userId); service.save(type); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response(STATUS,"success"); }  @RequestMapping(method = GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = GET, value = "id") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')" + " or @permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getById( @RequestParam("id") Long id); @RequestMapping(method = GET, value = "operational-status") ResponseEntity<OpenLmisResponse> getAllStatuses( ); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentType type, HttpServletRequest request); static final String EQUIPMENT_TYPE; static final String STATUS; static final String EQUIPMENT_TYPES; }