@Test public void shouldSave() throws Exception { EquipmentEnergyType type = new EquipmentEnergyType(); type.setName("Test"); controller.save(type); verify(service).save(type); }
@RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType){ try { service.save(energyType); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Energy Name Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response("status","success"); }
EquipmentEnergyTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType){ try { service.save(energyType); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Energy Name Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response("status","success"); } }
EquipmentEnergyTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType){ try { service.save(energyType); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Energy Name Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response("status","success"); }  }
EquipmentEnergyTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType){ try { service.save(energyType); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Energy Name Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response("status","success"); }  @RequestMapping(value="list",method= GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')" + " or @permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType); @RequestMapping(method = GET, value = "{id}") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value="id") Long id); }
EquipmentEnergyTypeController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType){ try { service.save(energyType); }catch(DuplicateKeyException exp){ return OpenLmisResponse.error("Duplicate Energy Name Exists in DB.", HttpStatus.BAD_REQUEST); } return OpenLmisResponse.response("status","success"); }  @RequestMapping(value="list",method= GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')" + " or @permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentEnergyType energyType); @RequestMapping(method = GET, value = "{id}") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value="id") Long id);  }