PrivilegeDefinitionReader implements PrivilegeConstants { @Nullable PrivilegeDefinition readDefinition(@NotNull String privilegeName) { if (!privilegesTree.exists() || !privilegesTree.hasChild(privilegeName)) { return null; } else { Tree definitionTree = privilegesTree.getChild(privilegeName); return (isPrivilegeDefinition(definitionTree)) ? PrivilegeUtil.readDefinition(definitionTree) : null; } } PrivilegeDefinitionReader(@NotNull Root root);   }
@Test public void testReadInvalidDefinition() throws Exception { assertNull(reader.readDefinition("invalid")); }
@Test public void testReadNonExisting() { assertNull(reader.readDefinition("nonexisting")); }
@Test public void testReadDefinition() { assertNotNull(reader.readDefinition(JCR_READ)); }
@Test public void testMissingPermissionRoot() throws Exception { ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository(); Root tmpRoot = repo.login(null, null).getLatestRoot(); try { PrivilegeDefinitionReader reader = new PrivilegeDefinitionReader(tmpRoot); assertNull(reader.readDefinition(JCR_READ)); } finally { tmpRoot.getContentSession().close(); } }