### Question:
Files { public static String checkDir(final String dir) { return checkDir(dir, false); }  static void ensureDir(final String dir); static void ensureDir(final String dir, final boolean checkWrite); static void ensureDir(final File dir); static void ensureDir(final File dir, final boolean checkWrite); static String checkDir(final String dir); static String checkDir(final String dir, final boolean checkWrite); static String checkDir(final File dir); static String checkDir(final File dir, final boolean checkWrite); static String checkFile(final File file, final boolean checkWrite); static void ensureMv(final String src, final String dest); static void ensureMv(final String src, final String dest, final boolean overwrite); static void ensureMv(final File src, final File dest); static void ensureMv(final File src, final File dest, final boolean overwrite); static String mv(final String src, final String dest); static String mv(final String src, final String dest, final boolean overwrite); static String mv(final File src, final File dest); static String mv(final File src, final File dest, final boolean overwrite); static File tmpDir();  }### Answer:
@Test public void testCheckDirString() throws Exception { String ret = Files.checkDir("file"); assertNull(ret); }
@Test public void testCheckDirNoDir() throws Exception { File file = mock(File.class); expect(file.exists()).andReturn(false); expect(file.mkdirs()).andReturn(false); replay(file); String err = Files.checkDir(file); assertEquals(err, "Directory, 'EasyMock for class java.io.File' does not exist; and cannot be created"); }
@Test public void testCheckDirIsDirectory() throws Exception { File file = mock(File.class); expect(file.exists()).andReturn(true); expect(file.isDirectory()).andReturn(false); replay(file); String err = Files.checkDir(file); assertEquals(err, "File, 'EasyMock for class java.io.File' is not a directory."); }
@Test public void testCheckDirCanRead() throws Exception { File file = mock(File.class); expect(file.exists()).andReturn(true); expect(file.isDirectory()).andReturn(true); expect(file.canRead()).andReturn(false); replay(file); String err = Files.checkDir(file); assertEquals(err, "Directory, 'EasyMock for class java.io.File' cannot be read."); }
@Test public void testCheckDirCanExecute() throws Exception { File file = mock(File.class); expect(file.exists()).andReturn(true); expect(file.isDirectory()).andReturn(true); expect(file.canRead()).andReturn(true); expect(file.canExecute()).andReturn(false); replay(file); String err = Files.checkDir(file); assertEquals(err, "Directory contents for 'EasyMock for class java.io.File' cannot be listed."); }
@Test public void testCheckDirCheckWrite() throws Exception { File file = mock(File.class); expect(file.exists()).andReturn(true); expect(file.isDirectory()).andReturn(true); expect(file.canRead()).andReturn(true); expect(file.canExecute()).andReturn(true); expect(file.canWrite()).andReturn(false); replay(file); String err = Files.checkDir(file, true); assertEquals(err, "Directory, 'EasyMock for class java.io.File' cannot be written to."); }
@Test(expected = IllegalArgumentException.class) public void testCheckDirNull() throws Exception { File file = null; Files.checkDir(file); }