### Question:
GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode = 0775; if (fileAttributes.length > 0) { mode = GlusterFileAttributes.parseAttrs(fileAttributes); } int ret = GLFS.glfs_mkdir(((GlusterFileSystem) path.getFileSystem()).getVolptr(), path.toString(), mode); if (ret < 0) { throw new IOException(path.toString()); } }  @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem getFileSystem(URI uri); @Override Path getPath(URI uri); @Override SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes); @Override FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs); @Override DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter); @Override void createDirectory(Path path, FileAttribute<?>... fileAttributes); @Override void delete(Path path); @Override void copy(Path path, Path path2, CopyOption... copyOptions); @Override void move(Path path, Path path2, CopyOption... copyOptions); @Override boolean isSameFile(Path path, Path path2); @Override boolean isHidden(Path path); @Override FileStore getFileStore(Path path); @Override void checkAccess(Path path, AccessMode... accessModes); @Override V getFileAttributeView(Path path, Class<V> vClass, LinkOption... linkOptions); @Override A readAttributes(Path path, Class<A> type, LinkOption... linkOptions); @Override Map<String, Object> readAttributes(Path path, String s, LinkOption... linkOptions); @Override void setAttribute(Path path, String s, Object o, LinkOption... linkOptions); @Override Path readSymbolicLink(Path link); @Override void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs); static final String GLUSTER; static final int GLUSTERD_PORT; static final String TCP; }### Answer:
@Test(expected = FileAlreadyExistsException.class) public void testCreateDirectory_whenFileOrDirectoryExists() throws IOException { mockStatic(Files.class); when(Files.exists(mockPath)).thenReturn(true); provider.createDirectory(mockPath); }
@Test(expected = IOException.class) public void testCreateDirectory_whenParentDirectoryDoesNotExist() throws IOException { mockStatic(Files.class); GlusterPath parentPath = Mockito.mock(GlusterPath.class); doReturn(parentPath).when(mockPath).getParent(); when(Files.exists(parentPath)).thenReturn(false); provider.createDirectory(mockPath); }
@Test public void testCreateDirectory() throws IOException { helperCreateDirectory(false, false); }