### Question:
FileUtils { public static File locateDirectory(String directoryName) { if (directoryName == null) { return null; } File aFile = locateFileOrDirectory(directoryName); if ((aFile != null) && aFile.isDirectory()) { return aFile; } return null; } private  FileUtils(); static File locateFile(String fileName); static File locateDirectory(String directoryName); static String readFile(String fileName);  }### Answer:
@Test public void testLocateFileAsDirectory() { String fileName = "/"; File aFile = FileUtils.locateDirectory(fileName); assertNotNull(aFile); assertTrue(aFile.canRead()); fileName = "."; aFile = FileUtils.locateDirectory(fileName); assertNotNull(aFile); assertTrue(aFile.getAbsolutePath().startsWith(System.getProperty("user.dir"))); aFile = FileUtils.locateDirectory(null); assertNull(aFile); }
@Test public void testValidRelativePathExists() { File aFile = FileUtils.locateDirectory(RELATIVE_PATH_NAME); assertNotNull(aFile); }
@Test public void testValidRelativePathNotExists() { String fileName = "relative-path-not-exist/"; File aFile = FileUtils.locateDirectory(fileName); assertNull(aFile); }
@Test public void testInvalidPathException() { thrown.expect(InvalidPathException.class); String fileName = "invalid-path:\0/"; FileUtils.locateDirectory(fileName); }
@Test public void loadFileFromRelativePath() { String fileName = "../"; File aFile = FileUtils.locateDirectory(fileName); assertNotNull(aFile); assertTrue(aFile.canRead()); }