### Question:
DefaultFileManager implements FileManager { @Override public synchronized boolean deleteFile(final String filepath) { final File file = new File(directory, filepath); return deleteFile(file); } 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_deleteFile_FileNotExists() throws IOException { File testFileSetup = new File(rootTestDirectory, TEST_FILE_NAME); testFileSetup.delete(); testFileSetup.createNewFile(); Assert.assertTrue(testFileSetup.isFile()); File testFile = new File(rootTestDirectory, TEST_FILE_NAME); Assert.assertTrue(testFile.isFile()); Assert.assertTrue(target.deleteFile(testFile)); Assert.assertFalse(testFile.exists()); }
@Test public void test_WhenFileNotExists_deleteFile_ReturnsTrue(){ File testFileSetup = new File(rootTestDirectory, TEST_FILE_NAME); testFileSetup.delete(); Assert.assertFalse(testFileSetup.exists()); File testFile = new File(rootTestDirectory, TEST_FILE_NAME); Assert.assertFalse(testFile.exists()); Assert.assertTrue(target.deleteFile(testFile)); Assert.assertFalse(testFile.exists()); }
@Test public void test_WhenFileSystemReadOnlyAndFileExists_deleteFile_ReturnsFalseNoException() throws IOException{ File testFileSetup = new File(rootTestDirectory, TEST_FILE_NAME); testFileSetup.delete(); testFileSetup.createNewFile(); Assert.assertTrue(testFileSetup.isFile()); File testFile = new File(rootTestDirectory, TEST_FILE_NAME); Assert.assertTrue(testFile.exists()); rootTestDirectory.setReadOnly(); Assert.assertFalse(target.deleteFile(testFile)); Assert.assertTrue(testFile.exists()); rootTestDirectory.setWritable(true); }