### Question:
Directory implements Serializable { public File relativeFile(final File file, final boolean mustBeChild) { final File f; if (file.isAbsolute()) { f = file; } else if (!mustBeChild) { return file; } else { f = getFile(file); } return relativePath(getFile(), f, mustBeChild); } Directory();  Directory(final File directory); static FileFilter getMatchAllFilesFilter(); void create(); File getFile(); File getFile(final File child); File[] listContents(final FileFilter filter); File[] listContents(final FileFilter filter,
                             final boolean includeDirectories,
                             final boolean absolutePaths); void deleteContents(); void delete(); File rebaseFromCWD(final File file); File relativeFile(final File file, final boolean mustBeChild); List<File> rebasePath(final String path); boolean isParentOf(final File file); void copyTo(final Directory target, final boolean incremental); String[] getWarnings(); @Override int hashCode(); @Override boolean equals(final Object o);  }### Answer:
@Test public void testRelativeFileDot() throws Exception { final File result = new Directory().relativeFile(new File("."), false); assertEquals(new File("."), result); }
@Test public void testRelativeFileWithAbsoluteFile() throws Exception { final Directory directory = new Directory(getDirectory()); final File absoluteFile = new File("blah").getAbsoluteFile(); assertNull(directory.relativeFile(absoluteFile, true)); }
@Test public void relativeFileWithAbsoluteChild1() throws Exception { final File absoluteFile = new File(getDirectory(), "blah").getAbsoluteFile(); final Directory directory = new Directory(getDirectory()); final File result = directory.relativeFile(absoluteFile, false); assertTrue(!result.isAbsolute()); assertEquals("blah", result.getPath()); }
@Test public void testRelativeFileWithAbsouteChild2() throws Exception { final File absoluteFile = new File(getDirectory(), "blah").getAbsoluteFile(); final Directory directory = new Directory(getDirectory()); final File result = directory.relativeFile(absoluteFile, true); assertTrue(!result.isAbsolute()); assertEquals("blah", result.getPath()); }
@Test public void testRelativeFileWithRelativeChild() throws Exception { final File relaiveFile = new File("blah"); final Directory directory = new Directory(getDirectory()); final File result = directory.relativeFile(relaiveFile, true); assertTrue(!result.isAbsolute()); assertEquals("blah", result.getPath()); }
@Test public void testRelativeFileWithRelativeNonChild1() throws Exception { final File relativeFile = new File("../blah"); final Directory directory = new Directory(getDirectory()); assertNull(directory.relativeFile(relativeFile, true)); }
@Test public void testRelativeFileWithRelativeNonChild2() throws Exception { final File relativeFile = new File("../blah"); final Directory directory = new Directory(getDirectory()); final File result = directory.relativeFile(relativeFile, false); assertSame(relativeFile, result); }