DefaultVertexTraversal extends AbstractVertexTraversal implements VertexTraversal { @Override public <T> Optional<T> next() { Optional<Vertex> vertex = flow.apply(supplier.get()).tryNext(); return vertex.map(converter::toEntity); } DefaultVertexTraversal(Supplier<GraphTraversal<?, ?>> supplier,
                           Function<GraphTraversal<?, ?>, GraphTraversal<Vertex, Vertex>> flow,
                           GraphConverter converter); @Override VertexTraversal has(String propertyKey, Object value); @Override VertexTraversal has(String propertyKey); @Override VertexTraversal has(String propertyKey, P<?> predicate); @Override VertexTraversal has(T accessor, Object value); @Override VertexTraversal has(T accessor, P<?> predicate); @Override VertexTraversal out(String... labels); @Override VertexTraversal filter(Predicate<T> predicate); @Override EdgeTraversal outE(String... edgeLabels); @Override VertexTraversal in(String... labels); @Override EdgeTraversal inE(String... edgeLabels); @Override VertexTraversal both(String... labels); @Override EdgeTraversal bothE(String... edgeLabels); @Override VertexRepeatTraversal repeat(); @Override VertexTraversal limit(long limit); @Override VertexTraversal range(long start, long end); @Override VertexTraversal hasLabel(String label); @Override VertexTraversal hasLabel(Class<T> entityClass); @Override VertexTraversal hasLabel(P<String> predicate); @Override VertexTraversal hasNot(String propertyKey); @Override Optional<T> next(); @Override Stream<T> stream(); @Override Optional<T> getSingleResult(); @Override List<T> getResultList(); @Override Stream<T> next(int limit); @Override ValueMapTraversal valueMap(String... propertyKeys); @Override long count(); @Override VertexTraversalOrder orderBy(String property);  }
@Test public void shouldDefineLimit2() { List<Person> people = graphTemplate.getTraversalVertex(otavio.getId(), poliana.getId(), paulo.getId()). <Person>next(2) .collect(toList()); assertEquals(2, people.size()); assertThat(people, containsInAnyOrder(otavio, poliana)); }
@Test public void shouldNext() { Optional<?> next = graphTemplate.getTraversalVertex().next(); assertTrue(next.isPresent()); }
@Test public void shouldEmptyNext() { Optional<?> next = graphTemplate.getTraversalVertex(-12).next(); assertFalse(next.isPresent()); }