### Question:
CompiledJavaccFilesDirectoryFactory { public CompiledJavaccFilesDirectory getCompiledJavaccFilesDirectory(File outputDirectory, FileTree customAstClassesDirectory, File targetDirectory, Logger logger) { if ((outputDirectory == null) || !outputDirectory.exists() || !outputDirectory.isDirectory()) { throw new IllegalArgumentException("outputDirectory [" + outputDirectory + "] must be an existing directory"); } if (customAstClassesDirectory == null) { throw new IllegalArgumentException("customAstClassesDirectory [" + outputDirectory + "] must not be null"); } if ((targetDirectory == null) || !targetDirectory.exists() || !targetDirectory.isDirectory()) { throw new IllegalArgumentException("targetDirectory [" + targetDirectory + "] must be an existing directory"); } return new CompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, targetDirectory, logger); }  CompiledJavaccFilesDirectory getCompiledJavaccFilesDirectory(File outputDirectory, FileTree customAstClassesDirectory, File targetDirectory, Logger logger);  }### Answer:
@Test public void createInstance() { CompiledJavaccFilesDirectory directory = factory.getCompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, targetDirectory, null); assertNotNull(directory); }
@Test(expected = IllegalArgumentException.class) public void outputDirectoryMustBeProvided() { factory.getCompiledJavaccFilesDirectory(null, customAstClassesDirectory, targetDirectory, null); }
@Test(expected = IllegalArgumentException.class) public void outputDirectoryMustExist() { File inexistingOutputDirectory = new File(getClass().getResource("/").getFile() + "doesNotExist"); factory.getCompiledJavaccFilesDirectory(inexistingOutputDirectory, customAstClassesDirectory, targetDirectory, null); }
@Test(expected = IllegalArgumentException.class) public void outputDirectoryMustBeADirectory() { File invalidOutputDirectory = new File(getClass().getResource("/javacc/input/JavaccOutputTest.jj").getFile()); factory.getCompiledJavaccFilesDirectory(invalidOutputDirectory, customAstClassesDirectory, targetDirectory, null); }
@Test(expected = IllegalArgumentException.class) public void customAstClassesDirectoryMustBeProvided() { factory.getCompiledJavaccFilesDirectory(outputDirectory, null, targetDirectory, null); }
@Test(expected = IllegalArgumentException.class) public void targetDirectoryMustBeProvided() { factory.getCompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, null, null); }
@Test(expected = IllegalArgumentException.class) public void targetDirectoryMustExist() { File inexistingOutputDirectory = new File(getClass().getResource("/").getFile() + "doesNotExist"); factory.getCompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, inexistingOutputDirectory, null); }
@Test(expected = IllegalArgumentException.class) public void targetDirectoryMustBeADirectory() { File invalidOutputDirectory = new File(getClass().getResource("/javacc/input/JavaccOutputTest.jj").getFile()); factory.getCompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, invalidOutputDirectory, null); }