### Question:
FileOperations { @Nonnull public static FileIOError deleteDir (@Nonnull final File aDir) { ValueEnforcer.notNull (aDir, "Directory"); if (!FileHelper.existsDir (aDir)) return EFileIOErrorCode.SOURCE_DOES_NOT_EXIST.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); if (isExceptionOnDeleteRoot ()) { if (aDir.getAbsoluteFile ().getParent () == null) throw new IllegalArgumentException ("Aren't we deleting the full drive: '" + aDir.getAbsolutePath () + "'"); } final File aParentDir = aDir.getParentFile (); if (aParentDir != null && !aParentDir.canWrite ()) return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); try { Files.delete (aDir.toPath ()); return EFileIOErrorCode.NO_ERROR.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); } catch (final NoSuchFileException ex) { return EFileIOErrorCode.SOURCE_DOES_NOT_EXIST.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); } catch (final DirectoryNotEmptyException ex) { return EFileIOErrorCode.OPERATION_FAILED.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); } catch (final IOException ex) { return EFileIOErrorCode.IO_ERROR.getAsIOError (EFileIOOperation.DELETE_DIR, aDir); } catch (final SecurityException ex) { return EFileIOErrorCode.getSecurityAsIOError (EFileIOOperation.DELETE_DIR, ex); } } private  FileOperations(); static boolean isExceptionOnDeleteRoot(); static void setExceptionOnDeleteRoot(final boolean bExceptionOnDeleteRoot); @Nonnull static FileIOError createDir(@Nonnull final File aDir); @Nonnull static FileIOError createDirIfNotExisting(@Nonnull final File aDir); @Nonnull static FileIOError createDirRecursive(@Nonnull final File aDir); @Nonnull static FileIOError createDirRecursiveIfNotExisting(@Nonnull final File aDir); @Nonnull static FileIOError deleteDir(@Nonnull final File aDir); @Nonnull static FileIOError deleteDirIfExisting(@Nonnull final File aDir); @Nonnull static FileIOError deleteDirRecursive(@Nonnull final File aDir); @Nonnull static FileIOError deleteDirRecursiveIfExisting(@Nonnull final File aDir); @Nonnull static FileIOError deleteFile(@Nonnull final File aFile); @Nonnull static FileIOError deleteFileIfExisting(@Nonnull final File aFile); @Nonnull static FileIOError renameFile(@Nonnull final File aSourceFile, @Nonnull final File aTargetFile); @Nonnull static FileIOError renameDir(@Nonnull final File aSourceDir, @Nonnull final File aTargetDir); @Nonnull static FileIOError copyFile(@Nonnull final File aSourceFile, @Nonnull final File aTargetFile); @Nonnull static FileIOError copyDirRecursive(@Nonnull final File aSourceDir, @Nonnull final File aTargetDir); static final boolean DEFAULT_EXCEPTION_ON_DELETE_ROOT; }### Answer:
@Test public void testDeleteDir () { final File aDir = new File ("deldir.test"); try { _expectedError (FileOperations.deleteDir (aDir), EFileIOErrorCode.SOURCE_DOES_NOT_EXIST); assertFalse (FileHelper.existsDir (aDir)); _expectedSuccess (FileOperations.createDir (aDir)); assertEquals (0, FileHelper.getDirectoryObjectCount (aDir)); _expectedSuccess (FileOperations.deleteDir (aDir)); assertFalse (FileHelper.existsDir (aDir)); } finally { FileOperations.deleteDirRecursive (aDir); } try { FileOperations.deleteDir (null); fail (); } catch (final NullPointerException ex) {} }