Search in sources :

Example 6 with Source

use of com.yahoo.search.pagetemplates.model.Source in project vespa by vespa-engine.

the class PageTemplateXMLReadingTestCase method assertCorrectSources.

static void assertCorrectSources(String expectedSourceNameString, PageTemplate page) {
    String[] expectedSourceNames = expectedSourceNameString.split(" ");
    Set<String> sourceNames = new HashSet<>();
    for (Source source : page.getSources()) sourceNames.add(source.getName());
    assertEquals("Expected " + expectedSourceNames.length + " elements in " + sourceNames, expectedSourceNames.length, sourceNames.size());
    for (String expectedSourceName : expectedSourceNames) assertTrue("Sources did not include '" + expectedSourceName + "'", sourceNames.contains(expectedSourceName));
}
Also used : Source(com.yahoo.search.pagetemplates.model.Source) HashSet(java.util.HashSet)

Example 7 with Source

use of com.yahoo.search.pagetemplates.model.Source in project vespa by vespa-engine.

the class PageTemplateXMLReadingTestCase method assertCorrectRichSerp.

protected void assertCorrectRichSerp(PageTemplate page) {
    assertNotNull("'rich serp' was read", page);
    Section rootSection = page.getSection();
    assertNotNull(rootSection);
    assertEquals("mainAndRight", rootSection.getLayout().getName());
    Section main = (Section) rootSection.elements(Section.class).get(0);
    assertEquals("row", main.getLayout().getName());
    assertEquals("main", main.getRegion());
    Section leftMain = (Section) main.elements(Section.class).get(0);
    assertEquals("column", leftMain.getLayout().getName());
    Section imageBar = (Section) leftMain.elements(Section.class).get(0);
    assertEquals("row", imageBar.getLayout().getName());
    assertEquals(5, imageBar.getMax());
    assertEquals("annealing", ((Choice) imageBar.elements(Source.class).get(0)).getMethod().toString());
    assertEquals("images", ((Source) ((Choice) imageBar.elements(Source.class).get(0)).alternatives().get(0).get(0)).getName());
    assertEquals("flickr", ((Source) ((Choice) imageBar.elements(Source.class).get(0)).alternatives().get(1).get(0)).getName());
    Section richElement = (Section) leftMain.elements(Section.class).get(1);
    assertEquals(1, richElement.getMax());
    assertEquals("[source 'local', source 'map', source 'video', source 'ticker', source 'weather']", richElement.elements(Source.class).toString());
    Section webResults = (Section) leftMain.elements(Section.class).get(2);
    assertEquals("-[rank]", webResults.getOrder().toString());
    assertEquals(10, webResults.getMax());
    assertEquals("[source 'web', source 'news']", webResults.elements(Source.class).toString());
    Section rightMain = (Section) main.elements(Section.class).get(1);
    assertEquals("column", rightMain.getLayout().getName());
    assertEquals("+[source]", rightMain.getOrder().toString());
    assertEquals("[source 'answers', source 'blogs', source 'twitter']", rightMain.elements(Source.class).toString());
    Section right = (Section) rootSection.elements(Section.class).get(1);
    assertEquals("column", right.getLayout().getName());
    assertEquals("right", right.getRegion());
    assertEquals("ads", ((Source) right.elements(Source.class).get(0)).getName());
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Section(com.yahoo.search.pagetemplates.model.Section) Source(com.yahoo.search.pagetemplates.model.Source)

Aggregations

Source (com.yahoo.search.pagetemplates.model.Source)7 Section (com.yahoo.search.pagetemplates.model.Section)3 Choice (com.yahoo.search.pagetemplates.model.Choice)2 Renderer (com.yahoo.search.pagetemplates.model.Renderer)2 IntentModel (com.yahoo.search.intent.model.IntentModel)1 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)1 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)1 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)1 PageElement (com.yahoo.search.pagetemplates.model.PageElement)1 SectionHitGroup (com.yahoo.search.pagetemplates.result.SectionHitGroup)1 HashSet (java.util.HashSet)1