@Test public void shouldGetRoleById() throws Exception { Role role = new Role(); Long roleId = 1L; when(roleRightsService.getRole(roleId)).thenReturn(role); OpenLmisResponse response = controller.get(roleId).getBody(); assertThat((Role) response.getData().get(ROLE), is(role)); verify(roleRightsService).getRole(roleId); }
@RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { ResponseEntity<OpenLmisResponse> response = response(ROLE, roleRightsService.getRole(id)); response.getBody().addData(RIGHT_TYPE, roleRightsService.getRightTypeForRoleId(id)); return response; }
RoleRightsController extends BaseController { @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { ResponseEntity<OpenLmisResponse> response = response(ROLE, roleRightsService.getRole(id)); response.getBody().addData(RIGHT_TYPE, roleRightsService.getRightTypeForRoleId(id)); return response; } }
RoleRightsController extends BaseController { @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { ResponseEntity<OpenLmisResponse> response = response(ROLE, roleRightsService.getRole(id)); response.getBody().addData(RIGHT_TYPE, roleRightsService.getRightTypeForRoleId(id)); return response; }  }
RoleRightsController extends BaseController { @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { ResponseEntity<OpenLmisResponse> response = response(ROLE, roleRightsService.getRole(id)); response.getBody().addData(RIGHT_TYPE, roleRightsService.getRightTypeForRoleId(id)); return response; }  @RequestMapping(value = "/rights", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> getAllRights(); @RequestMapping(value = "/roles", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> createRole(@RequestBody Role role, HttpServletRequest request); @RequestMapping(value = "/roles", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE, MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/roles/list", method = GET) ResponseEntity<OpenLmisResponse> getAllReadonly(); @RequestMapping(value = "/roles-flat", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE, MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAllRolesFlat(); @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); @RequestMapping(value = "/roles/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> updateRole(@PathVariable("id") Long id, @RequestBody Role role, HttpServletRequest request); @RequestMapping(value = "facility/{facilityId}/program/{programId}/rights", method = GET) ResponseEntity<OpenLmisResponse> getRightsForUserAndFacilityProgram(@PathVariable("facilityId") Long facilityId, @PathVariable("programId") Long programId, HttpServletRequest httpServletRequest); @RequestMapping(value="/roles/getList",method= RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> getRoleList(HttpServletRequest request); }
RoleRightsController extends BaseController { @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") public ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id) { ResponseEntity<OpenLmisResponse> response = response(ROLE, roleRightsService.getRole(id)); response.getBody().addData(RIGHT_TYPE, roleRightsService.getRightTypeForRoleId(id)); return response; }  @RequestMapping(value = "/rights", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> getAllRights(); @RequestMapping(value = "/roles", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> createRole(@RequestBody Role role, HttpServletRequest request); @RequestMapping(value = "/roles", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE, MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(value = "/roles/list", method = GET) ResponseEntity<OpenLmisResponse> getAllReadonly(); @RequestMapping(value = "/roles-flat", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE, MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAllRolesFlat(); @RequestMapping(value = "/roles/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> get(@PathVariable("id") Long id); @RequestMapping(value = "/roles/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> updateRole(@PathVariable("id") Long id, @RequestBody Role role, HttpServletRequest request); @RequestMapping(value = "facility/{facilityId}/program/{programId}/rights", method = GET) ResponseEntity<OpenLmisResponse> getRightsForUserAndFacilityProgram(@PathVariable("facilityId") Long facilityId, @PathVariable("programId") Long programId, HttpServletRequest httpServletRequest); @RequestMapping(value="/roles/getList",method= RequestMethod.GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_ROLE')") ResponseEntity<OpenLmisResponse> getRoleList(HttpServletRequest request); static final String ROLE; static final String ROLES_MAP; static final String RIGHTS; static final String RIGHT_TYPE; }