kwin commented on code in PR #257: URL: https://github.com/apache/jackrabbit-filevault/pull/257#discussion_r1032557632
########## vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageIT.java: ########## @@ -28,50 +29,48 @@ import javax.jcr.RepositoryException; import org.apache.jackrabbit.commons.JcrUtils; +import org.apache.jackrabbit.util.Text; import org.apache.jackrabbit.vault.fs.api.PathFilterSet; import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener; import org.apache.jackrabbit.vault.fs.config.ConfigurationException; import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter; -import org.apache.jackrabbit.util.Text; import org.junit.Before; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * {@code ImportTests}... + * Tests of coverage dump functionality. */ public class DumpCoverageIT extends IntegrationTestBase { - /** - * default logger - */ - private static final Logger log = LoggerFactory.getLogger(DumpCoverageIT.class); - public static final String TEST_ROOT = "/testroot"; - public static final String[] ALL_PAGES = { - TEST_ROOT + "/content", - TEST_ROOT + "/content/en", - TEST_ROOT + "/content/en/foo", - TEST_ROOT + "/content/en/bar", - TEST_ROOT + "/content/fr", - TEST_ROOT + "/content/fr/foo" - }; - public static final String[] LANGUAGE_PAGES = { - TEST_ROOT + "/content/en", - TEST_ROOT + "/content/en/foo", - TEST_ROOT + "/content/en/bar", - TEST_ROOT + "/content/fr", - TEST_ROOT + "/content/fr/foo" - }; - public static String[] ALL_PATHS; + public static final List<String> ENGLISH_PAGES = Arrays + .asList(new String[] { TEST_ROOT + "/content/en", TEST_ROOT + "/content/en/foo", TEST_ROOT + "/content/en/bar" }); Review Comment: ```suggestion .asList(TEST_ROOT + "/content/en", TEST_ROOT + "/content/en/foo", TEST_ROOT + "/content/en/bar"); ``` ########## vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java: ########## @@ -146,8 +146,7 @@ void dumpCoverage(@NotNull Node rootNode, @NotNull ProgressTrackerListener liste throws RepositoryException; /** - * Dumps the coverage of this filter using the given session. The traversal starts - * at the common ancestor of all filter sets. If {@code skipJcrContent} is {@code true} + * Dumps the coverage of this filter using the given session. If {@code skipJcrContent} is {@code true} Review Comment: Maybe you can also clarify the parameter `listener`. Instead of "listener to report progress" rather "listener which receives coverage information" ########## vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java: ########## @@ -580,27 +581,49 @@ public void dumpCoverage(javax.jcr.Node rootNode, ProgressTrackerListener listen /** * {@inheritDoc} */ - public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) - throws RepositoryException { + public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) throws RepositoryException { ProgressTracker tracker = new ProgressTracker(listener); - // get common ancestor - Tree<PathFilterSet> tree = new Tree<>(); - for (PathFilterSet set: nodesFilterSets) { - tree.put(set.getRoot(), set); - } - String rootPath = tree.getRootPath(); - javax.jcr.Node rootNode; - if (session.nodeExists(rootPath)) { - rootNode = session.getNode(rootPath); - } else if (session.nodeExists("/")) { - log.warn("Common ancestor {} not found. Using root node", rootPath); - rootNode = session.getRootNode(); - rootPath = "/"; - } else { - throw new PathNotFoundException("Common ancestor " + rootPath+ " not found."); - } - log.debug("Starting coverage dump at {} (skipJcrContent={})", rootPath, skipJcrContent); - dumpCoverage(rootNode, tracker, skipJcrContent); + + List<javax.jcr.Node> nodes = new ArrayList<>(); Review Comment: What is this variable being used for? ########## vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java: ########## @@ -580,27 +581,49 @@ public void dumpCoverage(javax.jcr.Node rootNode, ProgressTrackerListener listen /** * {@inheritDoc} */ - public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) - throws RepositoryException { + public void dumpCoverage(Session session, ProgressTrackerListener listener, boolean skipJcrContent) throws RepositoryException { ProgressTracker tracker = new ProgressTracker(listener); - // get common ancestor - Tree<PathFilterSet> tree = new Tree<>(); - for (PathFilterSet set: nodesFilterSets) { - tree.put(set.getRoot(), set); - } - String rootPath = tree.getRootPath(); - javax.jcr.Node rootNode; - if (session.nodeExists(rootPath)) { - rootNode = session.getNode(rootPath); - } else if (session.nodeExists("/")) { - log.warn("Common ancestor {} not found. Using root node", rootPath); - rootNode = session.getRootNode(); - rootPath = "/"; - } else { - throw new PathNotFoundException("Common ancestor " + rootPath+ " not found."); - } - log.debug("Starting coverage dump at {} (skipJcrContent={})", rootPath, skipJcrContent); - dumpCoverage(rootNode, tracker, skipJcrContent); + + List<javax.jcr.Node> nodes = new ArrayList<>(); + for (String path : getNodesToDump()) { + if (session.nodeExists(path)) { + nodes.add(session.getNode(path)); + dumpCoverage(session.getNode(path), tracker, skipJcrContent); + } else { + log.warn("Node {} not found (and thus will not be dumped)", path); + } + } + } + + /** + * @return list of nodes to descend from for dumping + */ + private List<String> getNodesToDump() { Review Comment: maybe rather `getEntryNodesRelevantForCoverage()` ########## vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageIT.java: ########## @@ -28,50 +29,48 @@ import javax.jcr.RepositoryException; import org.apache.jackrabbit.commons.JcrUtils; +import org.apache.jackrabbit.util.Text; import org.apache.jackrabbit.vault.fs.api.PathFilterSet; import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener; import org.apache.jackrabbit.vault.fs.config.ConfigurationException; import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter; -import org.apache.jackrabbit.util.Text; import org.junit.Before; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * {@code ImportTests}... + * Tests of coverage dump functionality. */ public class DumpCoverageIT extends IntegrationTestBase { - /** - * default logger - */ - private static final Logger log = LoggerFactory.getLogger(DumpCoverageIT.class); - public static final String TEST_ROOT = "/testroot"; - public static final String[] ALL_PAGES = { - TEST_ROOT + "/content", - TEST_ROOT + "/content/en", - TEST_ROOT + "/content/en/foo", - TEST_ROOT + "/content/en/bar", - TEST_ROOT + "/content/fr", - TEST_ROOT + "/content/fr/foo" - }; - public static final String[] LANGUAGE_PAGES = { - TEST_ROOT + "/content/en", - TEST_ROOT + "/content/en/foo", - TEST_ROOT + "/content/en/bar", - TEST_ROOT + "/content/fr", - TEST_ROOT + "/content/fr/foo" - }; - public static String[] ALL_PATHS; + public static final List<String> ENGLISH_PAGES = Arrays + .asList(new String[] { TEST_ROOT + "/content/en", TEST_ROOT + "/content/en/foo", TEST_ROOT + "/content/en/bar" }); + + public static final List<String> FRENCH_PAGES = Arrays + .asList(new String[] { TEST_ROOT + "/content/fr", TEST_ROOT + "/content/fr/foo" }); Review Comment: ```suggestion .asList(TEST_ROOT + "/content/fr", TEST_ROOT + "/content/fr/foo"); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org