@Test public void shouldSaveVendorUsers() throws Exception { VendorUser vu = new VendorUser(); vu.setUser(new User(2L, "theUser")); vu.setVendor(new Vendor()); ResponseEntity<OpenLmisResponse> response = controller.saveVendorUsers(vu, request); assertThat(vu, is(response.getBody().getData().get("vendorUser"))); assertThat(response.getBody().getSuccessMsg(), is(notNullValue())); }
@RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request) { vendorUser.setModifiedBy(loggedInUserId(request)); try { vendorUserService.save(vendorUser); } catch (DataException e) { return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = OpenLmisResponse.success( messageService.message("message.equipment.vendor.associated.with.user")); successResponse.getBody().addData(VENDOR_USER, vendorUser); return successResponse; }
VendorUserController extends BaseController { @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request) { vendorUser.setModifiedBy(loggedInUserId(request)); try { vendorUserService.save(vendorUser); } catch (DataException e) { return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = OpenLmisResponse.success( messageService.message("message.equipment.vendor.associated.with.user")); successResponse.getBody().addData(VENDOR_USER, vendorUser); return successResponse; } }
VendorUserController extends BaseController { @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request) { vendorUser.setModifiedBy(loggedInUserId(request)); try { vendorUserService.save(vendorUser); } catch (DataException e) { return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = OpenLmisResponse.success( messageService.message("message.equipment.vendor.associated.with.user")); successResponse.getBody().addData(VENDOR_USER, vendorUser); return successResponse; }  }
VendorUserController extends BaseController { @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request) { vendorUser.setModifiedBy(loggedInUserId(request)); try { vendorUserService.save(vendorUser); } catch (DataException e) { return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = OpenLmisResponse.success( messageService.message("message.equipment.vendor.associated.with.user")); successResponse.getBody().addData(VENDOR_USER, vendorUser); return successResponse; }  @RequestMapping(value = "getAllUsersForVendor/{vendorId}", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllUsersForVendor(@PathVariable(value = "vendorId") Long vendorId); @RequestMapping(value = "getAllUsersAvailableForVendor", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllUsersAvailableForVendor(); @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request); @RequestMapping(value="remove/{vendorId}/{userId}", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="vendorId") Long vendorId, @PathVariable(value="userId") Long userId); }
VendorUserController extends BaseController { @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request) { vendorUser.setModifiedBy(loggedInUserId(request)); try { vendorUserService.save(vendorUser); } catch (DataException e) { return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = OpenLmisResponse.success( messageService.message("message.equipment.vendor.associated.with.user")); successResponse.getBody().addData(VENDOR_USER, vendorUser); return successResponse; }  @RequestMapping(value = "getAllUsersForVendor/{vendorId}", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllUsersForVendor(@PathVariable(value = "vendorId") Long vendorId); @RequestMapping(value = "getAllUsersAvailableForVendor", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllUsersAvailableForVendor(); @RequestMapping(value="saveNewUserForVendor", method = RequestMethod.POST,headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> saveVendorUsers(@RequestBody VendorUser vendorUser, HttpServletRequest request); @RequestMapping(value="remove/{vendorId}/{userId}", method = RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value="vendorId") Long vendorId, @PathVariable(value="userId") Long userId); static final String VENDOR_USER; static final String USERS; }