@Test public void testGetRolesForUser() throws Exception { List<String> userAuths = dao.getRolesForUser(null, "marissa"); // $NON-NLS-1$ if (logger.isDebugEnabled()) { logger.debug("testGetRolesForUser(): Roles: " + userAuths); // $NON-NLS-1$ } assertNotNull(userAuths); assertTrue(userAuths.size() == 2); assertEquals(userAuths.get(0), "ROLE_ONE"); // $NON-NLS-1$ assertEquals(userAuths.get(1), "ROLE_TWO"); // $NON-NLS-1$ }
@Test public void testGetRolesForUserSorted() throws Exception { dao.setRoleComparator(new DefaultRoleComparator()); List<String> authorities = dao.getRolesForUser(null, "scott"); // $NON-NLS-1$ if (logger.isDebugEnabled()) { logger.debug("testGetRolesForUser(): Roles: " + authorities); // $NON-NLS-1$ } assertTrue( authorities.indexOf(new GrantedAuthorityImpl("ROLE_ONE")) < authorities.indexOf(new GrantedAuthorityImpl("ROLE_THREE"))); }