ChecklistExporter { List<ForcedRoot> traverse(final Session session, final List<String> paths) throws RepositoryException { final List<ForcedRoot> roots = new ArrayList<>(); final NamespaceMapping mapping = new NamespaceMapping(new SessionNamespaceResolver(session)); for (String path : paths) { if (session.nodeExists(path)) { nodeToRoot(session.getNode(path), mapping).ifPresent(roots::add); } } return roots; } private  ChecklistExporter(final List<Op> operations,
                              final List<String> exportTypeDefs,
                              final List<Rule> pathScopes,
                              final List<Rule> nodeTypeFilters,
                              final List<JcrNs> jcrNamespaces); void updateChecklist(final WriterOpener writerOpener,
                                final Session session,
                                final Checklist checklist,
                                final ForcedRootUpdatePolicy updatePolicy); List<ForcedRoot> findRoots(final Session session); static final ForcedRootUpdatePolicy DEFAULT_UPDATE_POLICY; static final String COVARIANT_PREFIX; }
@Test public void testTraverse() throws Exception { TestUtil.withInMemoryRepo(session -> { TestUtil.installCndFromURL(session, getClass().getResource("/sling_nodetypes.cnd")); for (int i = 0; i < 5; i++) { JcrUtils.getOrCreateByPath("/test/node" + i, "nt:folder", session); } final ChecklistExporter exporter = new ChecklistExporter.Builder().build(); List<ForcedRoot> roots = exporter.traverse(session, Arrays.asList("/test/node0", "/test/node2", "/test/node4", "/test/node6")); ForcedRoot root0 = roots.stream().filter(root -> "/test/node0".equals(root.getPath())).findFirst().orElse(null); assertNotNull("root0 should not be null", root0); assertEquals("root0 primaryType should be nt:folder", "nt:folder", root0.getPrimaryType()); ForcedRoot root1 = roots.stream().filter(root -> "/test/node1".equals(root.getPath())).findFirst().orElse(null); assertNull("root1 should be null", root1); ForcedRoot root2 = roots.stream().filter(root -> "/test/node2".equals(root.getPath())).findFirst().orElse(null); assertNotNull("root2 should not be null", root2); assertEquals("root2 primaryType should be nt:folder", "nt:folder", root2.getPrimaryType()); ForcedRoot root6 = roots.stream().filter(root -> "/test/node6".equals(root.getPath())).findFirst().orElse(null); assertNull("root6 should be null", root6); }); }