### Question:
ChecksumGeneratorImpl implements ChecksumGenerator { protected boolean isExcludedSubTree(final Node node, final ChecksumGeneratorOptions options) throws RepositoryException { for (String exclude : options.getExcludedSubTrees()) { if (isPathFragmentMatch(node, exclude)) { return true; } } return false; }  Map<String, String> generateChecksums(Session session, String path); Map<String, String> generateChecksums(Session session, String path, ChecksumGeneratorOptions options);  }### Answer:
@Test public void testIsExcludedSubTree_ByPath() throws RepositoryException { session.getRootNode() .addNode("content") .addNode("one", "nt:unstructured") .addNode("two", "nt:unstructured") .addNode("three", "nt:unstructured"); CustomChecksumGeneratorOptions opts = new CustomChecksumGeneratorOptions(); opts.addExcludedSubTrees(new String[]{ "one/two" }); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content/one"), opts)); assertTrue(checksumGenerator.isExcludedSubTree(session.getNode("/content/one/two"), opts)); }
@Test public void testIsExcludedNodeName_ByPath() throws RepositoryException { session.getRootNode() .addNode("content") .addNode("one", "nt:unstructured") .addNode("two", "nt:unstructured") .addNode("three", "nt:unstructured"); CustomChecksumGeneratorOptions opts = new CustomChecksumGeneratorOptions(); opts.addExcludedSubTrees(new String[]{ "one/two" }); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content/one"), opts)); assertTrue(checksumGenerator.isExcludedSubTree(session.getNode("/content/one/two"), opts)); }
@Test public void testIsExcludedSubTree_ByNodeType() throws RepositoryException { session.getRootNode() .addNode("content") .addNode("one", "nt:unstructured") .addNode("two", "nt:unstructured") .addNode("three", "nt:unstructured"); CustomChecksumGeneratorOptions opts = new CustomChecksumGeneratorOptions(); opts.addExcludedSubTrees(new String[]{ "one/two" }); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content"), opts)); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content/one"), opts)); assertTrue(checksumGenerator.isExcludedSubTree(session.getNode("/content/one/two"), opts)); }
@Test public void testIsExcludedNodeName_ByNodeType() throws RepositoryException { Node content = session.getRootNode().addNode("content"); Node parent1 = content.addNode("parent1", "nt:unstructured"); Node parent2 = content.addNode("parent2", "sling:Folder"); parent1.addNode("child", "nt:unstructured"); parent2.addNode("child", "nt:unstructured"); CustomChecksumGeneratorOptions opts = new CustomChecksumGeneratorOptions(); opts.addExcludedSubTrees(new String[]{ "[sling:Folder]/child" }); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content"), opts)); assertFalse(checksumGenerator.isExcludedSubTree(session.getNode("/content/parent1/child"), opts)); assertTrue(checksumGenerator.isExcludedSubTree(session.getNode("/content/parent2/child"), opts)); }