use of com.yahoo.search.federation.vespa.ResultBuilder in project vespa by vespa-engine.
the class ResultBuilderTestCase method testSimpleResult.
public void testSimpleResult() {
boolean gotErrorDetails = false;
ResultBuilder r = new ResultBuilder();
Result res = r.parse("file:src/test/java/com/yahoo/prelude/searcher/test/testhit.xml", new Query("?query=a"));
assertEquals(3, res.getConcreteHitCount());
assertEquals(4, res.getHitCount());
ErrorHit e = (ErrorHit) res.hits().get(0);
// is no way of nuking an existing error if the details exist.
for (Iterator<?> i = e.errorIterator(); i.hasNext(); ) {
ErrorMessage err = (ErrorMessage) i.next();
assertEquals(5, err.getCode());
String details = err.getDetailedMessage();
if (details != null) {
gotErrorDetails = true;
assertEquals("An error as ordered", details.trim());
}
}
assertTrue("Error details are missing", gotErrorDetails);
assertEquals(new URI("http://def"), res.hits().get(1).getId());
assertEquals("test/stuff\\tsome/other", res.hits().get(2).getField("category"));
assertEquals("<field>habla</field>" + "<hi>blbl</hi><br /><>&fdlkkgj</field>;lk<a b=\"1\" c=\"2\" />" + "<x><y><z /></y></x>", res.hits().get(3).getField("annoying").toString());
}
use of com.yahoo.search.federation.vespa.ResultBuilder in project vespa by vespa-engine.
the class ResultBuilderTestCase method testWeirdDocumentID.
public void testWeirdDocumentID() {
ResultBuilder r = new ResultBuilder();
Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/idhits.xml", new Query("?query=a"));
assertNull(res.hits().getError());
assertEquals(3, res.hits().size());
assertEquals(new URI("nalle"), res.hits().get(0).getId());
assertEquals(new URI("tralle"), res.hits().get(1).getId());
assertEquals(new URI("kalle"), res.hits().get(2).getId());
}
use of com.yahoo.search.federation.vespa.ResultBuilder in project vespa by vespa-engine.
the class ResultBuilderTestCase method testNestedResult.
public void testNestedResult() {
ResultBuilder r = new ResultBuilder();
Result res = r.parse("file:src/test/java/com/yahoo/search/federation/vespa/test/nestedhits.xml", new Query("?query=a"));
assertNull(res.hits().getError());
assertEquals(3, res.hits().size());
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", res.hits().get(0).getField("guid").toString());
HitGroup g1 = (HitGroup) res.hits().get(1);
HitGroup g2 = (HitGroup) res.hits().get(2);
assertEquals(15, g1.size());
assertEquals("reward_for_thumb", g1.get(1).getField("id").toString());
assertEquals(10, g2.size());
HitGroup g3 = (HitGroup) g2.get(3);
assertEquals("badge", g3.getTypeString());
assertEquals(2, g3.size());
assertEquals("badge/Topic Explorer 5", g3.get(0).getField("name").toString());
}
Aggregations