Search in sources :

Example 6 with DeterministicResolver

use of com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver in project vespa by vespa-engine.

the class PageTestCase method testExecution.

@Test
public void testExecution() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("Page.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, "PageResult.xml", new PageTemplateSet());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Resolver(com.yahoo.search.pagetemplates.engine.Resolver) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) PageTemplateSet(com.yahoo.prelude.templates.PageTemplateSet) Result(com.yahoo.search.Result) Resolution(com.yahoo.search.pagetemplates.engine.Resolution) Test(org.junit.Test)

Example 7 with DeterministicResolver

use of com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver in project vespa by vespa-engine.

the class PageWithSourceRendererTestCase method testExecution.

@Test
public void testExecution() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("PageWithSourceRenderer.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
    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, "PageWithSourceRendererResult.xml", new PageTemplateSet());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Resolver(com.yahoo.search.pagetemplates.engine.Resolver) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) PageTemplateSet(com.yahoo.prelude.templates.PageTemplateSet) Result(com.yahoo.search.Result) Resolution(com.yahoo.search.pagetemplates.engine.Resolution) Test(org.junit.Test)

Example 8 with DeterministicResolver

use of com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver in project vespa by vespa-engine.

the class TwoSectionsFourSourcesTestCase method testExecutionMissingTwoSources.

@Test
public void testExecutionMissingTwoSources() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    result.hits().add(createHits("source1", 3));
    result.hits().add(createHits("source3", 12));
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertGroupedSource3Source1(section1.asList());
    assertEquals(0, section2.size());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 9 with DeterministicResolver

use of com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver in project vespa by vespa-engine.

the class TwoSectionsFourSourcesTestCase method testExecutionMissingAllSources.

@Test
public void testExecutionMissingAllSources() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertEquals(0, section1.size());
    assertEquals(0, section2.size());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Example 10 with DeterministicResolver

use of com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver in project vespa by vespa-engine.

the class TwoSectionsFourSourcesTestCase method testExecutionMissingOneSource.

@Test
public void testExecutionMissingOneSource() {
    // Create the page template
    Choice page = Choice.createSingleton(importPage("TwoSectionsFourSources.xml"));
    // Create a federated result
    Query query = new Query();
    Result result = new Result(query);
    result.hits().add(createHits("source1", 3));
    result.hits().add(createHits("source3", 12));
    result.hits().add(createHits("source4", 13));
    new Organizer().organize(page, new DeterministicResolver().resolve(page, query, result), result);
    // Check execution:
    // Two subsections with two sources each, the first grouped the second blended
    assertEquals(2, result.hits().size());
    HitGroup section1 = (HitGroup) result.hits().get(0);
    HitGroup section2 = (HitGroup) result.hits().get(1);
    assertGroupedSource3Source1(section1.asList());
    assertEqualHitGroups(createHits("source4", 10), section2);
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Query(com.yahoo.search.Query) Organizer(com.yahoo.search.pagetemplates.engine.Organizer) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Result(com.yahoo.search.Result) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Aggregations

DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)14 Choice (com.yahoo.search.pagetemplates.model.Choice)14 Query (com.yahoo.search.Query)12 Result (com.yahoo.search.Result)12 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)12 Test (org.junit.Test)12 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)10 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)9 HitGroup (com.yahoo.search.result.HitGroup)5 PageTemplateSet (com.yahoo.prelude.templates.PageTemplateSet)4 Section (com.yahoo.search.pagetemplates.model.Section)2 PageElement (com.yahoo.search.pagetemplates.model.PageElement)1 Renderer (com.yahoo.search.pagetemplates.model.Renderer)1 Source (com.yahoo.search.pagetemplates.model.Source)1 ArrayList (java.util.ArrayList)1