ResultRowToAuthorizable implements Function<ResultRow, Authorizable> { @Nullable @Override public Authorizable apply(@Nullable ResultRow row) { return getAuthorizable(row); } ResultRowToAuthorizable(@NotNull UserManagerImpl userManager, @NotNull Root root,
                            @Nullable AuthorizableType targetType); @Nullable @Override Authorizable apply(@Nullable ResultRow row);  }
@Test public void testApplyNullRow() { assertNull(groupRrta.apply(null)); }
@Test public void testRowToNonExistingTree() { PropertyValue propValue = PropertyValues.newPath("/path/to/nonExisting/tree"); ResultRow row = when(mock(ResultRow.class).getValue(QueryConstants.JCR_PATH)).thenReturn(propValue).getMock(); assertNull(groupRrta.apply(row)); }
@Test public void testRowToRootTree() { assertNull(groupRrta.apply(createResultRow(PathUtils.ROOT_PATH))); }
@Test public void testRowToUserTree() throws Exception { User user = getTestUser(); ResultRow row = createResultRow(user.getPath()); assertNull(groupRrta.apply(row)); Authorizable a = userRrta.apply(row); assertNotNull(a); assertEquals(user.getID(), a.getID()); }
@Test public void testRowToUserSubTree() throws Exception { User user = getTestUser(); Tree t = root.getTree(user.getPath()); t = TreeUtil.addChild(t, "child", NT_OAK_UNSTRUCTURED); ResultRow row = createResultRow(t.getPath()); assertNull(groupRrta.apply(row)); Authorizable a = userRrta.apply(row); assertNotNull(a); assertEquals(user.getID(), a.getID()); }
@Test public void testRowToNonExistingUserSubTree() throws Exception { User user = getTestUser(); ResultRow row = createResultRow(PathUtils.concat(user.getPath(), "child")); assertNull(userRrta.apply(row)); }
@Test public void testRowNonAccessibleUserTree() throws Exception { User user = getTestUser(); String userPath = user.getPath(); try (ContentSession cs = login(new SimpleCredentials(user.getID(), user.getID().toCharArray()))) { Root r = cs.getLatestRoot(); ResultRowToAuthorizable rrta = new ResultRowToAuthorizable(new UserManagerImpl(r, getPartialValueFactory(), getSecurityProvider()), r, null); assertNull(rrta.apply(createResultRow(userPath))); } }