@Test public void shouldReturnTrueIfUserHasRequiredPermission() throws Exception { Right right1 = new Right(RightName.CONFIGURE_RNR, ADMIN); Right right2 = new Right(RightName.AUTHORIZE_REQUISITION, REQUISITION); List<Right> rights = new ArrayList<>(asList(right1,right2)); Long userId = 1L; when(roleRightsService.getRights(userId)).thenReturn(rights); assertThat(evaluator.hasPermission(userId, "AUTHORIZE_REQUISITION, CONFIGURE_RNR"), is(true)); assertThat(evaluator.hasPermission(userId, "AUTHORIZE_REQUISITION"), is(true)); assertThat(evaluator.hasPermission(userId, "MANAGE_FACILITY"), is(false)); }
public Boolean hasPermission(Long userId, String commaSeparatedRights) { List<Right> userRights = roleRightService.getRights(userId); return any(userRights, RightUtil.contains(getRightNamesList(commaSeparatedRights))); }
PermissionEvaluator { public Boolean hasPermission(Long userId, String commaSeparatedRights) { List<Right> userRights = roleRightService.getRights(userId); return any(userRights, RightUtil.contains(getRightNamesList(commaSeparatedRights))); } }
PermissionEvaluator { public Boolean hasPermission(Long userId, String commaSeparatedRights) { List<Right> userRights = roleRightService.getRights(userId); return any(userRights, RightUtil.contains(getRightNamesList(commaSeparatedRights))); }  }
PermissionEvaluator { public Boolean hasPermission(Long userId, String commaSeparatedRights) { List<Right> userRights = roleRightService.getRights(userId); return any(userRights, RightUtil.contains(getRightNamesList(commaSeparatedRights))); }  Boolean hasPermission(Long userId, String commaSeparatedRights); Boolean hasReportingPermission(Long userId); }
PermissionEvaluator { public Boolean hasPermission(Long userId, String commaSeparatedRights) { List<Right> userRights = roleRightService.getRights(userId); return any(userRights, RightUtil.contains(getRightNamesList(commaSeparatedRights))); }  Boolean hasPermission(Long userId, String commaSeparatedRights); Boolean hasReportingPermission(Long userId);  }