### Question:
GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } }  @Override Iterator<Path> iterator(); @Override void close(); void open(GlusterPath path);  }### Answer:
@Test public void testClose_whenAlreadyClosed() throws IOException { stream.setDirHandle(dirHandle); stream.setClosed(true); mockStatic(GLFS.class); stream.close(); verifyStatic(Mockito.never()); GLFS.glfs_close(dirHandle); }
@Test public void testClose() throws IOException { stream.setDirHandle(dirHandle); mockStatic(GLFS.class); Mockito.when(GLFS.glfs_close(dirHandle)).thenReturn(0); stream.close(); verifyStatic(); GLFS.glfs_close(dirHandle); }