@Test
public void testQuery() throws Exception {

    TestUtil.withInMemoryRepo(session -> {
        TestUtil.installCndFromURL(session, getClass().getResource("/sling_nodetypes.cnd"));
        final int sample = 5;
        List<String> paths = IntStream.range(0, sample).mapToObj(val -> "/test/node" + val).collect(Collectors.toList());
        assertEquals("should generate n paths: ", sample, paths.size());
        paths.forEach(Fun.tryOrVoid1(path ->
                JcrUtils.getOrCreateByPath(path, "nt:folder",
                        "sling:Folder", session, true)));
        final ChecklistExporter exporter = new ChecklistExporter.Builder().build();
        List<ForcedRoot> byXPath = exporter.query(session, "//element(*, sling:Folder)");
        for (String path : paths) {
            ForcedRoot root0 = byXPath.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
            assertNotNull(String.format("root for path %s should not be null", path), root0);
            assertEquals(String.format("root primaryType for path %s should be sling:Folder", path),
                    "sling:Folder", root0.getPrimaryType());
        }
        List<ForcedRoot> bySQL2 = exporter.query(session, "select * from [sling:Folder]");
        for (String path : paths) {
            ForcedRoot root0 = bySQL2.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
            assertNotNull(String.format("root for path %s should not be null", path), root0);
            assertEquals(String.format("root primaryType for path %s should be sling:Folder", path),
                    "sling:Folder", root0.getPrimaryType());
        }
    });
}