### Question:
JavaccSourceFileVisitor extends EmptyFileVisitor { @Override public void visitFile(FileVisitDetails fileDetails) { if (isValidSourceFileForTask(fileDetails)) { compiler.compile(computeInputDirectory(fileDetails), fileDetails.getRelativePath()); } else { compiler.getLogger().debug("Skipping file {} as it is not supported by program {}", fileDetails.getFile().getAbsolutePath(), compiler.getProgramName()); } } JavaccSourceFileVisitor(SourceFileCompiler compiler); @Override void visitFile(FileVisitDetails fileDetails);  }### Answer:
@Test public void givenAJavaccSourceFileWhenVisitFileThenDelegatesToTaskCompile() { FileVisitDetails fileDetails = mock(FileVisitDetails.class); when(fileDetails.getFile()).thenReturn(new File(JAVACC_SOURCE_FILE)); when(fileDetails.getName()).thenReturn(JAVACC_SOURCE_FILE); when(fileDetails.getPath()).thenReturn(JAVACC_SOURCE_FILE); sourceVisitor.visitFile(fileDetails); verify(compiler).compile(any(File.class), any(RelativePath.class)); }
@Test public void givenAJavaSourceFileWhenVisitFileThenDoesNotDelegateToTaskCompile() { FileVisitDetails fileDetails = mock(FileVisitDetails.class); File fileToVisit = new File(JAVA_SOURCE_FILE); when(fileDetails.getFile()).thenReturn(fileToVisit); when(fileDetails.getName()).thenReturn(JAVA_SOURCE_FILE); when(fileDetails.getPath()).thenReturn(JAVA_SOURCE_FILE); sourceVisitor.visitFile(fileDetails); verify(compiler, never()).compile(any(File.class), any(RelativePath.class)); verify(logger).debug(anyString(), eq(fileToVisit.getAbsolutePath()), eq("JavaCC")); }