use of com.yahoo.search.pagetemplates.engine.Organizer in project vespa by vespa-engine.
the class ChoiceOfSubsectionsTestCase method testExecution.
@Test
public void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("ChoiceOfSubsections.xml"));
// Create a federated result
Query query = new Query();
Result result = new Result(query);
result.hits().add(createHits("source1", 3));
result.hits().add(createHits("source2", 3));
result.hits().add(createHits("source3", 3));
result.hits().add(createHits("source4", 3));
new Organizer().organize(page, new DeterministicResolverAssertingMethod().resolve(page, query, result), result);
// Check execution:
// Two subsections with one source each
assertEquals(2, result.hits().size());
HitGroup section1 = (HitGroup) result.hits().get(0);
HitGroup section2 = (HitGroup) result.hits().get(1);
assertEqualHitGroups(createHits("source2", 3), section1);
assertEqualHitGroups(createHits("source4", 3), section2);
// Check rendering
assertRendered(result, "ChoiceOfSubsectionsResult.xml");
}
use of com.yahoo.search.pagetemplates.engine.Organizer in project vespa by vespa-engine.
the class ChoicesTestCase method testExecution.
@Test
public void testExecution() {
// Create the page template (second alternative will be chosen)
List<PageElement> pages = new ArrayList<>();
pages.add(importPage("AnySource.xml"));
pages.add(importPage("Choices.xml"));
Choice page = Choice.createSingletons(pages);
// Create a federated result
Query query = new Query();
Result result = new Result(query);
result.hits().add(createHits("news", 3));
result.hits().add(createHits("web", 3));
result.hits().add(createHits("blog", 3));
result.hits().add(createHits("images", 3));
// Resolve
Resolver resolver = new DeterministicResolver();
Resolution resolution = resolver.resolve(page, query, result);
// Execute
Organizer organizer = new Organizer();
organizer.organize(page, resolution, result);
// Check rendering
assertRendered(result, "ChoicesResult.xml");
}
use of com.yahoo.search.pagetemplates.engine.Organizer in project vespa by vespa-engine.
the class ChoiceOfRenderersTestCase method testExecution.
// This test is order dependent. Fix this!!
@Test
public void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("ChoiceOfRenderers.xml"));
// Create a federated result
Query query = new Query();
Result result = new Result(query);
result.hits().add(createHits("source1", 3));
result.hits().add(createHits("source2", 3));
result.hits().add(createHits("source3", 3));
// Resolve
Resolver resolver = new DeterministicResolver();
Resolution resolution = resolver.resolve(page, query, result);
assertEquals(1, resolution.getResolution((Choice) ((PageTemplate) page.get(0).get(0)).getSection().elements(Renderer.class).get(0)));
assertEquals(2, resolution.getResolution((Choice) ((PageTemplate) page.get(0).get(0)).getSection().elements(Renderer.class).get(1)));
// Execute
Organizer organizer = new Organizer();
organizer.organize(page, resolution, result);
assertEquals(6, result.getConcreteHitCount());
assertEquals(6, result.getHitCount());
// Check rendering
assertRendered(result, "ChoiceOfRenderersResult.xml");
}
use of com.yahoo.search.pagetemplates.engine.Organizer in project vespa by vespa-engine.
the class PageWithBlendingTestCase method testExecution.
@Test
public void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("PageWithBlending.xml"));
// Create a federated result
Query query = new Query();
Result result = new Result(query);
result.hits().add(createHits("news", 2));
result.hits().add(createHits("htmlSource", 1));
// Resolve (noop here)
Resolver resolver = new DeterministicResolver();
Resolution resolution = resolver.resolve(page, query, result);
// Execute
Organizer organizer = new Organizer();
organizer.organize(page, resolution, result);
// Check rendering
assertRendered(result, "PageWithBlendingResult.xml", new PageTemplateSet());
}
use of com.yahoo.search.pagetemplates.engine.Organizer in project vespa by vespa-engine.
the class SourceChoiceTestCase method testExecution.
@Test
public void testExecution() {
// Create the page template
Choice page = Choice.createSingleton(importPage("SourceChoice.xml"));
// Create a federated result
Query query = new Query();
Result result = new Result(query);
result.hits().add(createHits("web", 3));
result.hits().add(createHits("news", 3));
result.hits().add(createHits("blog", 3));
// Resolve (noop here)
Resolver resolver = new DeterministicResolver();
Resolution resolution = resolver.resolve(page, query, result);
// Execute
Organizer organizer = new Organizer();
organizer.organize(page, resolution, result);
// Check rendering
assertRendered(result, "SourceChoiceResult.xml", new PageTemplateSet(), true);
}
Aggregations