### Question:
CompiledJavaccFile { public void copyCustomAstClassToTargetDirectory(FileTree sourceTree) { logger.info("Not copying compiled file {} from {} to {} because it is overridden by the custom AST class {}", compiledJavaccFile, outputDirectory, targetDirectory, getCustomAstClassInputFile(sourceTree)); String packagePath = getPackageName(compiledJavaccFile).replaceAll("\\.", Matcher.quoteReplacement(File.separator)); File destination = new File(targetDirectory.getAbsolutePath() + File.separator + packagePath, compiledJavaccFile.getName()); logger.info("Copying custom AST class [{}] to [{}]", getCustomAstClassInputFile(sourceTree), destination); try { FileUtils.copyFile(getCustomAstClassInputFile(sourceTree), destination); } catch (IOException e) { String errorMessage = String.format("Could not copy %s to %s", getCustomAstClassInputFile(sourceTree), targetDirectory); throw new CompiledJavaccFileOperationException(errorMessage, e); } } CompiledJavaccFile(File file, File outputDirectory, FileTree customAstClassesDirectory, File targetDirectory, Logger logger); boolean customAstClassExists(); boolean customAstClassExists(FileTree fileTree); void copyCompiledFileToTargetDirectory(); void copyCustomAstClassToTargetDirectory(FileTree sourceTree); void ignoreCompiledFileAndUseCustomAstClassFromJavaSourceTree(FileTree javaSourceTree); @Override String toString();  }### Answer:
@Test public void copyCustomAstClassToTargetDirectory() { File expectedFile = new File(targetDirectory, "FileWithCorrespondingCustomAstClass.java"); assertFalse(expectedFile.exists()); File file = new File(outputDirectory, "FileWithCorrespondingCustomAstClass.java"); CompiledJavaccFile compiledJavaccFile = new CompiledJavaccFile(file, outputDirectory, customAstClassesDirectory, targetDirectory, logger); compiledJavaccFile.copyCustomAstClassToTargetDirectory(customAstClassesDirectory); assertTrue(expectedFile.exists()); }
@Test(expected = CompiledJavaccFileOperationException.class) public void copyCustomAstClassToTargetDirectoryFails() throws Exception { PowerMockito.mockStatic(FileUtils.class, Answers.CALLS_REAL_METHODS.get()); doThrow(new IOException()).when(FileUtils.class); FileUtils.copyFile(any(File.class), any(File.class)); File file = new File(outputDirectory, "FileWithCorrespondingCustomAstClass.java"); CompiledJavaccFile compiledJavaccFile = new CompiledJavaccFile(file, outputDirectory, customAstClassesDirectory, targetDirectory, logger); compiledJavaccFile.copyCustomAstClassToTargetDirectory(customAstClassesDirectory); }