FileManager { public static boolean deleteDirectory(@NonNull File file) { File[] contents = file.listFiles(); if (contents != null) { for (File f : contents) { deleteDirectory(f); } } return file.delete(); }  static synchronized void initialize(Context context); @SuppressWarnings("SameParameterValue") static String read(@NonNull String path); static String read(@NonNull File file); static byte[] readBytes(@NonNull File file); static void write(@NonNull String path, @NonNull String contents); static void write(@NonNull File file, @NonNull String contents); @SuppressWarnings("WeakerAccess") @NonNull static String[] getFilenames(@NonNull String path, @Nullable FilenameFilter filter); @SuppressWarnings("WeakerAccess") @Nullable static File lastModifiedFile(@NonNull String path, @Nullable FilenameFilter filter); @Nullable static File lastModifiedFile(@NonNull File dir, @Nullable FilenameFilter filter); static boolean delete(@NonNull String path); static boolean delete(@NonNull File file); static boolean deleteDirectory(@NonNull File file); static void cleanDirectory(@NonNull File directory); @SuppressWarnings("ResultOfMethodCallIgnored") static void mkdir(@NonNull String path);  }
@Test public void deleteFilesWhenFileListIsNull() throws IOException { spy(FileManager.class); File folder = mTemporaryFolder.newFolder(); assertTrue(folder.exists()); FileManager.deleteDirectory(folder); assertFalse(folder.exists()); verifyStatic(); FileManager.deleteDirectory(any(File.class)); }