@Test
    public void shouldFilterNoneFromIteratorWithoutHasNextCheckFirst() {
        final List<String> iterable = new ArrayList<>();
        iterable.add("test1");
        iterable.add("test2");
        iterable.add("test3");

        final Iterator<String> filteredItty = IteratorUtils.filter(iterable.iterator(), s -> s.startsWith("test"));
        assertEquals("test1",  filteredItty.next());
        assertEquals("test2",  filteredItty.next());
        assertEquals("test3",  filteredItty.next());
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java