JcrAllCommitHook implements PostValidationHook, PrivilegeConstants { @NotNull @Override public NodeState processCommit( NodeState before, NodeState after, CommitInfo info) { NodeBuilder builder = after.builder(); after.compareAgainstBaseState(before, new PrivilegeDiff(null, null, builder)); return builder.getNodeState(); }  @NotNull @Override NodeState processCommit(
            NodeState before, NodeState after, CommitInfo info); @Override String toString();  }
@Test public void testJcrAllNodeAdded() { root.getTree(PRIVILEGES_PATH).getChild(JCR_ALL).remove(); NodeState before = getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH)); Root r = adminSession.getLatestRoot(); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); }
@Test public void testJcrAllNodeWithoutAggregates() { NodeState before = getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH)); Root r = adminSession.getLatestRoot(); Tree t = r.getTree(PRIVILEGES_PATH); Tree jcrAll = t.getChild(JCR_ALL); jcrAll.removeProperty(REP_AGGREGATES); t.addChild("newPriv"); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); }
@Test public void testJcrAllNodeAlreadyContainsNewName() { NodeState before = getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH)); Root r = adminSession.getLatestRoot(); Tree t = r.getTree(PRIVILEGES_PATH); Tree jcrAll = t.getChild(JCR_ALL); jcrAll.setProperty(REP_AGGREGATES, ImmutableList.of("newPriv"), Type.NAMES); t.addChild("newPriv"); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); }
@Test public void testPrivilegesRootAdded() { root.getTree(PRIVILEGES_PATH).remove(); NodeState before = getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH)); Root r = adminSession.getLatestRoot(); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); }