### Question:
GlusterDirectoryIterator implements Iterator<GlusterPath> { @Override public GlusterPath next() { if (nextPath == null) { throw new NoSuchElementException("No more entries"); } return nextPath; }  @Override boolean hasNext(); @Override GlusterPath next(); @Override void remove();  }### Answer:
@Test(expected = NoSuchElementException.class) public void testNext_whenNoNext() { iterator.next(); }
@Test public void testNext() { iterator.setNextPath(fakeResultPath); GlusterPath path = iterator.next(); assertEquals(fakeResultPath, path); }