ChildNodeStateProvider { Iterator<NodeStateEntry> children() { return children(false); } ChildNodeStateProvider(Iterable<NodeStateEntry> entries, String path, Set<String> preferredPathElements); boolean hasChildNode(@NotNull String name); @NotNull NodeState getChildNode(@NotNull String name); long getChildNodeCount(long max); Iterable<String> getChildNodeNames(); @NotNull Iterable<? extends ChildNodeEntry> getChildNodeEntries();  }
@Test public void children() { Set<String> preferred = ImmutableSet.of("jcr:content", "x"); CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/e", preferred); assertEquals(singletonList("f"), copyOf(childNames(p.children()))); assertEquals(7, citr.getCount()); p = new ChildNodeStateProvider(citr, "/g", preferred); assertEquals(emptyList(), copyOf(childNames(p.children()))); }
@Test public void children2() { Set<String> preferred = ImmutableSet.of("b"); CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/b", "/a/b/c", "/a/b/c/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); assertEquals(singletonList("b"), copyOf(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/a/b", preferred); assertEquals(singletonList("c"), copyOf(childNames(p.children()))); assertEquals(5, citr.getCount()); p = new ChildNodeStateProvider(citr, "/a/b/c", preferred); assertEquals(singletonList("d"), copyOf(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/a/b/c/d", preferred); assertEquals(emptyList(), copyOf(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/h", preferred); assertEquals(emptyList(), copyOf(childNames(p.children()))); }
@Test public void childNames() { Set<String> preferred = ImmutableSet.of("jcr:content"); CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); assertEquals(5, citr.getCount()); }
@Test public void childNames2() { Set<String> preferred = ImmutableSet.of("jcr:content"); CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/jcr:content/metadata", "/a/c", "/a/c/status","/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); assertEquals(7, citr.getCount()); }