### Question:
PathOperations { @Nonnull public static FileIOError deleteDir (@Nonnull final Path aDir) { ValueEnforcer.notNull (aDir, "Directory"); final Path aRealDir = _getUnifiedPath (aDir); if (!aRealDir.toFile ().isDirectory ()) return EFileIOErrorCode.SOURCE_DOES_NOT_EXIST.getAsIOError (EFileIOOperation.DELETE_DIR, aRealDir); if (isExceptionOnDeleteRoot ()) { if (aRealDir.getParent () == null || aRealDir.getNameCount () == 0) throw new IllegalArgumentException ("Aren't we deleting the full drive: '" + aRealDir + "'"); } final Path aParentDir = aRealDir.getParent (); if (aParentDir != null && !Files.isWritable (aParentDir)) return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.DELETE_DIR, aRealDir); return _perform (EFileIOOperation.DELETE_DIR, Files::delete, aRealDir); } private  PathOperations(); static boolean isExceptionOnDeleteRoot(); static void setExceptionOnDeleteRoot(final boolean bExceptionOnDeleteRoot); @Nonnull static FileIOError createDir(@Nonnull final Path aDir); @Nonnull static FileIOError createDirIfNotExisting(@Nonnull final Path aDir); @Nonnull static FileIOError createDirRecursive(@Nonnull final Path aDir); @Nonnull static FileIOError createDirRecursiveIfNotExisting(@Nonnull final Path aDir); @Nonnull static FileIOError deleteDir(@Nonnull final Path aDir); @Nonnull static FileIOError deleteDirIfExisting(@Nonnull final Path aDir); @Nonnull static FileIOError deleteDirRecursive(@Nonnull final Path aDir); @Nonnull static FileIOError deleteDirRecursiveIfExisting(@Nonnull final Path aDir); @Nonnull static FileIOError deleteFile(@Nonnull final Path aFile); @Nonnull static FileIOError deleteFileIfExisting(@Nonnull final Path aFile); @Nonnull static FileIOError renameFile(@Nonnull final Path aSourceFile, @Nonnull final Path aTargetFile); @Nonnull static FileIOError renameDir(@Nonnull final Path aSourceDir, @Nonnull final Path aTargetDir); @Nonnull static FileIOError copyFile(@Nonnull final Path aSourceFile, @Nonnull final Path aTargetFile); @Nonnull static FileIOError copyDirRecursive(@Nonnull final Path aSourceDir, @Nonnull final Path aTargetDir); static final boolean DEFAULT_EXCEPTION_ON_DELETE_ROOT; }### Answer:
@Test public void testDeleteDir () { final Path aDir = Paths.get ("deldir.test"); try { _expectedError (PathOperations.deleteDir (aDir), EFileIOErrorCode.SOURCE_DOES_NOT_EXIST); assertFalse (Files.isDirectory (aDir)); _expectedSuccess (PathOperations.createDir (aDir)); assertEquals (0, PathHelper.getDirectoryObjectCount (aDir)); _expectedSuccess (PathOperations.deleteDir (aDir)); assertFalse (Files.isDirectory (aDir)); } finally { PathOperations.deleteDirRecursive (aDir); } try { PathOperations.deleteDir (null); fail (); } catch (final NullPointerException ex) {} }