CompositeTreePermission implements TreePermission { @NotNull @Override public TreePermission getChildPermission(@NotNull final String childName, @NotNull final NodeState childState) { return create(() -> treeProvider.createReadOnlyTree(tree, childName, childState), childName, childState, this, null); } private  CompositeTreePermission(@NotNull Tree tree, @NotNull TreeType type,
                                    @NotNull TreeProvider treeProvider,
                                    @NotNull TreeTypeProvider typeProvider,
                                    @NotNull AggregatedPermissionProvider[] providers,
                                    @NotNull TreePermission[] treePermissions, int cnt); @NotNull @Override TreePermission getChildPermission(@NotNull final String childName, @NotNull final NodeState childState); @Override boolean canRead(); @Override boolean canRead(@NotNull PropertyState property); @Override boolean canReadAll(); @Override boolean canReadProperties(); @Override boolean isGranted(long permissions); @Override boolean isGranted(long permissions, @NotNull PropertyState property);  }
@Test public void testSingle() { Class<? extends TreePermission> expected = fullScopeProvider.getTreePermission(rootTree, TreePermission.EMPTY).getClass(); TreePermission rootTp = createRootTreePermission(fullScopeProvider); assertCompositeTreePermission(false, rootTp); assertEquals(expected, rootTp.getClass()); TreePermission testTp = rootTp.getChildPermission("test", getTreeProvider().asNodeState(rootTree.getChild("test"))); assertEquals(expected, testTp.getClass()); }
@Test public void testMultiple() { TreePermission rootTp = createRootTreePermission(fullScopeProvider, fullScopeProvider); assertCompositeTreePermission(true, rootTp); TreePermission testTp = rootTp.getChildPermission("test", getTreeProvider().asNodeState(rootTree.getChild("test"))); assertCompositeTreePermission(true, testTp); }
@Test public void testMultipleNoRecurse() { TreePermission rootTp = createRootTreePermission(new NoScopeProvider(root), new NoScopeProvider(root)); assertCompositeTreePermission(true, rootTp); assertSame(TreePermission.EMPTY, rootTp.getChildPermission("test", getTreeProvider().asNodeState(rootTree.getChild("test")))); }
@Test public void testMultipleToSingle() { TreePermission rootTp = createRootTreePermission(fullScopeProvider, new NoScopeProvider(root), new NoScopeProvider(root)); assertCompositeTreePermission(true, rootTp); NodeState childState = getTreeProvider().asNodeState(rootTree.getChild("test")); TreePermission testTp = rootTp.getChildPermission("test", childState); TreePermission expected = fullScopeProvider.getTreePermission(rootTree, TreePermission.EMPTY).getChildPermission("test", childState); assertEquals(expected.getClass(), testTp.getClass()); }