use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testSecondHitIsGroup.
public void testSecondHitIsGroup() {
HitGroup root = new HitGroup();
root.add(new Hit("foo"));
HitGroup group = new HitGroup();
group.add(new Hit("bar"));
root.add(group);
Iterator<Hit> it = root.deepIterator();
assertTrue(it.hasNext());
assertEquals("foo", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("bar", it.next().getId().toString());
assertFalse(it.hasNext());
}
use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testDeep.
public void testDeep() {
HitGroup grandParent = new HitGroup();
grandParent.add(new Hit("a"));
HitGroup parent = new HitGroup();
parent.add(new Hit("b"));
HitGroup child = new HitGroup();
child.add(new Hit("c"));
HitGroup grandChild = new HitGroup();
grandChild.add(new Hit("d"));
child.add(grandChild);
child.add(new Hit("e"));
parent.add(child);
parent.add(new Hit("f"));
grandParent.add(parent);
grandParent.add(new Hit("g"));
Iterator<Hit> it = grandParent.deepIterator();
assertTrue(it.hasNext());
assertEquals("a", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("b", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("c", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("d", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("e", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("f", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("g", it.next().getId().toString());
assertFalse(it.hasNext());
}
use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testRemove.
public void testRemove() {
HitGroup hits = new HitGroup();
hits.add(new Hit("foo"));
hits.add(new Hit("bar"));
Iterator<Hit> it = hits.deepIterator();
try {
it.remove();
fail();
} catch (IllegalStateException e) {
// need to call next() first
}
assertTrue(it.hasNext());
assertEquals("foo", it.next().getId().toString());
assertTrue(it.hasNext());
try {
it.remove();
fail();
} catch (IllegalStateException e) {
// prefetch done
}
assertEquals("bar", it.next().getId().toString());
// no prefetch done
it.remove();
assertFalse(it.hasNext());
}
use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testEmpty.
public void testEmpty() {
HitGroup hits = new HitGroup();
Iterator<Hit> it = hits.deepIterator();
assertFalse(it.hasNext());
try {
it.next();
fail();
} catch (NoSuchElementException e) {
// regular iterator behavior
}
}
use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testFirstHitIsGroup.
public void testFirstHitIsGroup() {
HitGroup root = new HitGroup();
HitGroup group = new HitGroup();
group.add(new Hit("foo"));
root.add(group);
root.add(new Hit("bar"));
Iterator<Hit> it = root.deepIterator();
assertTrue(it.hasNext());
assertEquals("foo", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("bar", it.next().getId().toString());
assertFalse(it.hasNext());
}
Aggregations