### Question:
DefaultFileManager implements FileManager { @Override public synchronized File createDirectory(final String directoryPath) { final File dir = new File(directory, directoryPath); if (dir.mkdirs() || dir.isDirectory()) { return dir; } return null; } DefaultFileManager(final File rootDirectory); @Override synchronized File createDirectory(final String directoryPath); @Override File getDirectory(final String directoryPath); @Override Set<File> listFilesInDirectory(final String directoryPath); @Override Set<File> listFilesInDirectory(final File directory); @Override synchronized File createFile(final String filepath); @Override synchronized File createFile(final File file); @Override synchronized boolean deleteFile(final String filepath); @Override synchronized boolean deleteFile(final File file); @Override synchronized InputStream newInputStream(final String filepath); @Override synchronized InputStream newInputStream(final File file); @Override synchronized OutputStream newOutputStream(final String filepath, final boolean append); @Override synchronized OutputStream newOutputStream(final File file, final boolean append);  }### Answer:
@Test public void test_WhenDirectoryNotExists_createDirectory_DirectoryReturnedExists() throws IOException { File testDirectorySetup = new File(rootTestDirectory, TEST_DIR_NAME); testDirectorySetup.delete(); Assert.assertFalse(testDirectorySetup.exists()); File testDirectory = target.createDirectory(TEST_DIR_NAME); Assert.assertTrue(testDirectory.isDirectory()); }
@Test public void test_WhenDirectoryExists_createDirectory_ReturnsDirectory() throws IOException { File testDirectorySetup = new File(rootTestDirectory, TEST_DIR_NAME); testDirectorySetup.delete(); testDirectorySetup.mkdirs(); Assert.assertTrue(testDirectorySetup.isDirectory()); File testDirectory = target.createDirectory(TEST_DIR_NAME); Assert.assertTrue(testDirectory.isDirectory()); }
@Test public void test_WhenFileExistsWithSameName_createDirectory_ReturnsNull() throws IOException{ File testFileSetup = new File(rootTestDirectory, TEST_DIR_NAME); testFileSetup.delete(); testFileSetup.createNewFile(); Assert.assertTrue(testFileSetup.isFile()); File testDirectory = target.createDirectory(TEST_DIR_NAME); Assert.assertNull(testDirectory); }