### Question:
ElasticsearchQuery implements SimpleQuery<ElasticsearchQuery<K>>, Fetchable<K> { @Override public CloseableIterator<K> iterate() { return new IteratorAdapter<K>(fetch().iterator()); } ElasticsearchQuery(Client client, Function<SearchHit, K> transformer, ElasticsearchSerializer serializer); @Override CloseableIterator<K> iterate(); List<K> fetch(Path<?>... paths); @Override List<K> fetch(); K fetchFirst(Path<?>... paths); @Nullable @Override K fetchFirst(); K fetchOne(Path<?>... paths); @Nullable @Override K fetchOne(); QueryResults<K> fetchResults(Path<?>... paths); @Override QueryResults<K> fetchResults(); @Override long fetchCount(); @Override ElasticsearchQuery<K> limit(@Nonnegative long limit); @Override ElasticsearchQuery<K> offset(@Nonnegative long offset); @Override ElasticsearchQuery<K> restrict(QueryModifiers modifiers); @Override ElasticsearchQuery<K> orderBy(OrderSpecifier<?>... o); @Override ElasticsearchQuery<K> set(ParamExpression<T> param, T value); @Override ElasticsearchQuery<K> distinct(); @Override ElasticsearchQuery<K> where(Predicate... o); abstract String getIndex(); abstract String getType();  }### Answer:
@Test public void Iterate() { User a = addUser("A", "A", 10); User b = addUser("A1", "B", 10); User c = addUser("A2", "C", 10); refresh(indexUser, false); Iterator<User> i = where(user.firstName.startsWith("A")) .orderBy(user.firstName.asc()) .iterate(); assertEquals(a, i.next()); assertEquals(b, i.next()); assertEquals(c, i.next()); assertEquals(false, i.hasNext()); }
@Test public void Iterate() { User a = addUser("A", "A", 10); User b = addUser("A1", "B", 10); User c = addUser("A2", "C", 10); refresh(indexUser); Iterator<User> i = where(user.firstName.startsWith("A")) .orderBy(user.firstName.asc()) .iterate(); assertEquals(a, i.next()); assertEquals(b, i.next()); assertEquals(c, i.next()); assertEquals(false, i.hasNext()); }