### Question:
JacocoScannerPlugin extends AbstractScannerPlugin<FileResource,JacocoReportDescriptor> { boolean acceptsPath(String path) { return path.endsWith(jacocoFileName) || parentDirectoryHasAcceptableName(path); } JacocoScannerPlugin(); @Override boolean accepts(final FileResource item, String path, Scope scope); @Override JacocoReportDescriptor scan(final FileResource file, String path, Scope scope, Scanner scanner); static final String JQASSISTANT_PLUGIN_JACOCO_FILENAME; static final String JQASSISTANT_PLUGIN_JACOCO_DIRNAME; }### Answer:
@Test public void aValidPathShouldBeAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "/jacoco/test/jacocoTestReport.xml"; final boolean accepted = plugin.acceptsPath(path); assertTrue("A valid path should be accepted", accepted); }
@Test public void aValidPathAsRootShouldBeAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "/jacocoTestReport.xml"; final boolean accepted = plugin.acceptsPath(path); assertTrue("A valid path should be accepted", accepted); }
@Test public void anInvValidPathAsRootShouldNotBeAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "/jacocoTestReport.foo"; final boolean accepted = plugin.acceptsPath(path); assertFalse("An invalid path should not be accepted", accepted); }
@Test public void aValidSingleFileNameShouldBeAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "jacocoTestReport.xml"; final boolean accepted = plugin.acceptsPath(path); assertTrue("A valid path should be accepted", accepted); }
@Test public void aValidParentDirectoryShouldBeAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "/jacoco/report.xml"; final boolean accepted = plugin.acceptsPath(path); assertTrue("A valid parent directory should be accepted", accepted); }
@Test public void anInvalidPathGetsNotAccepted() throws IOException { JacocoScannerPlugin plugin = new JacocoScannerPlugin(); String path = "/pmd/report.xml"; final boolean accepted = plugin.acceptsPath(path); assertFalse("An invalid parent directory should not be accepted", accepted); }