FileIOUtils { public static boolean isValidDirectory(File directory) { if (!directory.exists()) { LOGGER.warn("Directory [" + directory.toPath() + "] does not exist."); return false; } if (!directory.isDirectory()) { LOGGER.error("Directory [" + directory.toPath() + "] is invalid. No extra plugins will be loaded"); return false; } if (!directory.canRead()) { LOGGER.error("Directory [" + directory.toPath() + "] is not readable. No extra plugins will be loaded"); return false; } return true; }  static boolean isDirWritable(final File dir); static boolean isValidDirectory(File directory); static void deleteDirectorySilently(final File dir); static File getDirectory(File parentDirectory, String folderName); static void moveFiles(File sourceDirectory, File destinationDiretory, String fileNamePattern); static void dumpNumberToFile(final Path filePath, final long num); static long readNumberFromFile(final Path filePath); static String getSourcePathFromClass(final Class<?> containedClass); static String getCanonicalPath(final File f); static Props loadOutputFileProps(final File file); static File createOutputPropsFile(final String prefix,
      final String suffix, final String workingDir); static int createDeepHardlink(final File sourceDir, final File destDir); static Pair<Integer, Integer> readUtf8File(final File file, final int offset,
      final int length, final OutputStream stream); static LogData readUtf8File(final File file, final int fileOffset, final int length); static JobMetaData readUtf8MetaDataFile(final File file, final int fileOffset,
      final int length); static Pair<Integer, Integer> getUtf8Range(final byte[] buffer, final int offset,
      final int length);  }
@Test public void testIsValidDirectory() { File file = Mockito.mock(File.class); Mockito.when(file.exists()).thenReturn(false); Assert.assertFalse(FileIOUtils.isValidDirectory(file)); Mockito.when(file.exists()).thenReturn(true); Mockito.when(file.isDirectory()).thenReturn(false); Assert.assertFalse(FileIOUtils.isValidDirectory(file)); Mockito.when(file.exists()).thenReturn(true); Mockito.when(file.isDirectory()).thenReturn(true); Mockito.when(file.canRead()).thenReturn(false); Assert.assertFalse(FileIOUtils.isValidDirectory(file)); Mockito.when(file.exists()).thenReturn(true); Mockito.when(file.isDirectory()).thenReturn(true); Mockito.when(file.canRead()).thenReturn(true); Assert.assertTrue(FileIOUtils.isValidDirectory(file)); }