ChildNodeStateProvider { public long getChildNodeCount(long max) { if (max == 1 && children().hasNext()) { return 1; } return size(children()); } 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 childCount() { 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); assertEquals(1, p.getChildNodeCount(1)); assertEquals(3, p.getChildNodeCount(2)); }