@Test public void shouldSave() throws Exception { Vendor vendor = new Vendor(); doNothing().when(service).save(vendor); ResponseEntity<OpenLmisResponse> response = controller.save(vendor); assertThat(response.getBody().getSuccessMsg(), is(notNullValue())); assertThat(vendor, is(response.getBody().getData().get("vendor"))); }
@RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor) { try { service.save(vendor); } catch (DuplicateKeyException exp) { return OpenLmisResponse.error("error.equipment.vendor.code.duplicate", HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success("message.equipment.successfully.saved.vendor"); response.getBody().addData(VENDOR, vendor); return response; }
VendorController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor) { try { service.save(vendor); } catch (DuplicateKeyException exp) { return OpenLmisResponse.error("error.equipment.vendor.code.duplicate", HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success("message.equipment.successfully.saved.vendor"); response.getBody().addData(VENDOR, vendor); return response; } }
VendorController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor) { try { service.save(vendor); } catch (DuplicateKeyException exp) { return OpenLmisResponse.error("error.equipment.vendor.code.duplicate", HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success("message.equipment.successfully.saved.vendor"); response.getBody().addData(VENDOR, vendor); return response; }  }
VendorController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor) { try { service.save(vendor); } catch (DuplicateKeyException exp) { return OpenLmisResponse.error("error.equipment.vendor.code.duplicate", HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success("message.equipment.successfully.saved.vendor"); response.getBody().addData(VENDOR, vendor); return response; }  @RequestMapping(method = GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = GET, value = "id") ResponseEntity<OpenLmisResponse> getById(@RequestParam("id") Long id); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor); @RequestMapping(value = "delete/{id}", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> remove(@PathVariable(value = "id") Long vendorId); }
VendorController extends BaseController { @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor) { try { service.save(vendor); } catch (DuplicateKeyException exp) { return OpenLmisResponse.error("error.equipment.vendor.code.duplicate", HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success("message.equipment.successfully.saved.vendor"); response.getBody().addData(VENDOR, vendor); return response; }  @RequestMapping(method = GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = GET, value = "id") ResponseEntity<OpenLmisResponse> getById(@RequestParam("id") Long id); @RequestMapping(value = "save", method = POST, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> save(@RequestBody Vendor vendor); @RequestMapping(value = "delete/{id}", method = GET, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> remove(@PathVariable(value = "id") Long vendorId); static final String VENDOR; }