public void testGetAuthorizableByPrincipal() throws RepositoryException, NotExecutableException { Authorizable auth = null; Set<Principal> principals = getPrincipalSetFromSession(superuser); for (Iterator<Principal> it = principals.iterator(); it.hasNext() && auth == null;) { Principal p = it.next(); auth = userMgr.getAuthorizable(p); } assertNotNull("At least one of the Sessions principal must be a known authorizable to the UserManager", auth); }
public void testGetAuthorizableByIdAndWrongType() throws NotExecutableException, RepositoryException { for (Principal principal : getPrincipalSetFromSession(superuser)) { Principal p = principal; Authorizable auth = userMgr.getAuthorizable(p); if (auth != null) { Class<? extends Authorizable> otherType = auth.isGroup() ? User.class : Group.class; try { userMgr.getAuthorizable(auth.getID(), otherType); fail("Wrong Authorizable type is not detected."); } catch (AuthorizableTypeException e) { // success } } } }
public void testGetAuthorizableById() throws RepositoryException, NotExecutableException { Authorizable auth = null; for (Principal principal : getPrincipalSetFromSession(superuser)) { Principal p = principal; auth = userMgr.getAuthorizable(p); if (auth != null) { Authorizable authByID = userMgr.getAuthorizable(auth.getID()); assertEquals("Equal ID expected", auth.getID(), authByID.getID()); } } }
public void testGetAuthorizableByIdAndType() throws NotExecutableException, RepositoryException { for (Principal principal : getPrincipalSetFromSession(superuser)) { Principal p = principal; Authorizable a = userMgr.getAuthorizable(p); if (a != null) { Authorizable authorizable = userMgr.getAuthorizable(a.getID(), a.getClass()); assertEquals("Equal ID expected", a.getID(), authorizable.getID()); authorizable = userMgr.getAuthorizable(a.getID(), Authorizable.class); assertEquals("Equal ID expected", a.getID(), authorizable.getID()); } } }