@Test
    public void testPeek() {
        final List<Integer> list = Arrays.asList(0, 1, 2, 3, 4, 5);
        final AtomicInteger counter = new AtomicInteger();
        final Iterator<Integer> it = IteratorUtils.peek(list.iterator(), i -> counter.incrementAndGet());
        for (int i = 0; i < list.size(); i++) {
            assertEquals(i, it.next().intValue());
        }
        assertEquals(list.size(), counter.get());
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java