ChildNodeStateProvider { public boolean hasChildNode(@NotNull String name) { return getChildNode(name).exists(); } 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 hasChildNode_InLimit() { 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")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); citr.reset(); assertTrue(p.hasChildNode("jcr:content")); assertEquals("Unexpected number of reads to get jcr:content", 2, citr.getCount()); citr.reset(); assertFalse(p.hasChildNode("x")); assertEquals("Unexpected number reads to conclude that preferred child 'x' is missing", 3, citr.getCount()); citr.reset(); assertTrue(p.hasChildNode("c")); assertEquals("Unexpected number reads to get 'c'", 3, citr.getCount()); citr.reset(); assertTrue(p.hasChildNode("d")); assertEquals("Unexpected number reads to get 'd'", 4, citr.getCount()); citr.reset(); assertFalse(p.hasChildNode("y")); assertEquals("Unexpected number reads to conclude that non-preferred child 'x' is missing", 5, citr.getCount()); }
@Test public void allPreferredReadable() { Set<String> preferred = ImmutableSet.of("x", "y"); CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/x", "/a/x/1", "/a/x/2", "/a/x/3", "/a/y")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); assertTrue(p.hasChildNode("x")); assertTrue(p.hasChildNode("y")); }