Search in sources :

Example 1 with Section

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

the class PageTemplateXMLReadingTestCase method assertCorrectSerp.

protected void assertCorrectSerp(PageTemplate page) {
    assertNotNull("'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("column", main.getLayout().getName());
    assertEquals("main", main.getRegion());
    assertEquals("web", ((Source) main.elements(Source.class).get(0)).getName());
    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 : Section(com.yahoo.search.pagetemplates.model.Section) Source(com.yahoo.search.pagetemplates.model.Source)

Example 2 with Section

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

the class PageTemplateXMLReadingTestCase method assertCorrectRicherSerp.

protected void assertCorrectRicherSerp(PageTemplate page) {
    assertNotNull("'richer serp' was read", page);
    // Check resolution as we go
    Resolver resolver = new DeterministicResolver();
    Resolution resolution = resolver.resolve(Choice.createSingleton(page), null, null);
    Section root = page.getSection();
    assertNotNull(root);
    assertEquals("column", root.getLayout().getName());
    assertEquals("Sections was correctly imported and combined with the section in this", 4, root.elements(Section.class).size());
    assertCorrectHeader((Section) root.elements(Section.class).get(0));
    Section body = (Section) root.elements(Section.class).get(1);
    assertEquals("mainAndRight", body.getLayout().getName());
    Section main = (Section) body.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());
    assertEquals(1, resolution.getResolution((Choice) leftMain.elements(Section.class).get(0)));
    Section imageBar = (Section) ((Choice) leftMain.elements(Section.class).get(0)).alternatives().get(0).get(0);
    assertEquals("row", imageBar.getLayout().getName());
    assertEquals(5, imageBar.getMax());
    assertEquals(2, ((Choice) imageBar.elements(Source.class).get(0)).alternatives().size());
    assertEquals("images", ((Source) ((Choice) imageBar.elements(Source.class).get(0)).alternatives().get(0).get(0)).getName());
    assertEquals(1, resolution.getResolution((Choice) imageBar.elements(Source.class).get(0)));
    assertEquals(1, resolution.getResolution((Choice) imageBar.elements(Renderer.class).get(0)));
    Source flickrSource = (Source) ((Choice) imageBar.elements(Source.class).get(0)).alternatives().get(1).get(0);
    assertEquals("flickr", flickrSource.getName());
    assertEquals(1, flickrSource.renderers().size());
    assertEquals("mouseOverImage", ((Renderer) flickrSource.renderers().get(0)).getName());
    Source twitpicSource = (Source) ((Choice) imageBar.elements(Source.class).get(0)).alternatives().get(1).get(1);
    assertEquals("twitpic", twitpicSource.getName());
    assertEquals(1, twitpicSource.parameters().size());
    assertEquals("origin=twitter", twitpicSource.parameters().get("filter"));
    assertEquals(2, ((Choice) twitpicSource.renderers().get(0)).alternatives().size());
    assertEquals(1, resolution.getResolution((Choice) twitpicSource.renderers().get(0)));
    Renderer mouseOverImageRenderer = (Renderer) ((Choice) twitpicSource.renderers().get(0)).alternatives().get(0).get(0);
    assertEquals("mouseOverImage", mouseOverImageRenderer.getName());
    assertEquals(2, mouseOverImageRenderer.parameters().size());
    assertEquals("5", mouseOverImageRenderer.parameters().get("hovertime"));
    assertEquals("#ff00ff", mouseOverImageRenderer.parameters().get("borderColor"));
    assertEquals("regularImage", ((Renderer) ((Choice) twitpicSource.renderers().get(0)).alternatives().get(1).get(0)).getName());
    assertEquals(2, ((Choice) imageBar.elements(Renderer.class).get(0)).alternatives().size());
    assertEquals("regularImageBox", ((Renderer) ((Choice) imageBar.elements(Renderer.class).get(0)).alternatives().get(0).get(0)).getName());
    assertEquals("newImageBox", ((Renderer) ((Choice) imageBar.elements(Renderer.class).get(0)).alternatives().get(1).get(0)).getName());
    Section richElement = (Section) ((Choice) leftMain.elements(Section.class).get(0)).get(0).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) ((Choice) leftMain.elements(Section.class).get(0)).get(1).get(0);
    assertEquals("+[source]", 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) body.elements(Section.class).get(1);
    assertEquals("column", right.getLayout().getName());
    assertEquals("right", right.getRegion());
    assertEquals("ads", ((Source) right.elements(Source.class).get(0)).getName());
    assertEquals("newAdBox", ((Renderer) right.elements(Renderer.class).get(0)).getName());
    assertEquals("-[rank] +clickProbability", right.getOrder().toString());
    assertCorrectFooter((Section) root.elements(Section.class).get(2));
    assertEquals("extraFooter", ((Section) root.elements(Section.class).get(3)).getId());
    // Check getSources()
    assertCorrectSources("ads answers blogs flickr global images local map news notifications " + "popularSearches ticker topArticles twitpic twitter video weather web", page);
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) Resolver(com.yahoo.search.pagetemplates.engine.Resolver) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Renderer(com.yahoo.search.pagetemplates.model.Renderer) Section(com.yahoo.search.pagetemplates.model.Section) Source(com.yahoo.search.pagetemplates.model.Source) Resolution(com.yahoo.search.pagetemplates.engine.Resolution)

Example 3 with Section

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

the class PageTemplateXMLReadingTestCase method assertCorrectSlottingSerp.

protected void assertCorrectSlottingSerp(PageTemplate page) {
    assertNotNull("'slotting serp' was read", page);
    Section rootSection = page.getSection();
    Section main = (Section) rootSection.elements(Section.class).get(0);
    assertEquals("-[rank]", main.getOrder().toString());
    assertEquals(Source.any, main.elements(Source.class).get(0));
    assertCorrectSources("* ads", page);
}
Also used : Section(com.yahoo.search.pagetemplates.model.Section)

Example 4 with Section

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

the class PageTemplateXMLReadingTestCase method assertCorrectIncluder.

protected void assertCorrectIncluder(PageTemplate page) {
    assertNotNull("'includer' was read", page);
    Resolution resolution = new DeterministicResolver().resolve(Choice.createSingleton(page), null, null);
    Section case1 = (Section) page.getSection().elements(Section.class).get(0);
    assertCorrectHeader((Section) case1.elements(Section.class).get(0));
    assertCorrectFooter((Section) case1.elements(Section.class).get(1));
    Section case2 = (Section) page.getSection().elements(Section.class).get(1);
    assertCorrectHeader((Section) ((Choice) case2.elements(Section.class).get(0)).get(0).get(0));
    assertCorrectFooter((Section) ((Choice) case2.elements(Section.class).get(0)).get(1).get(0));
    assertEquals(1, resolution.getResolution((Choice) case2.elements(Section.class).get(0)));
    Section case3 = (Section) page.getSection().elements(Section.class).get(2);
    assertCorrectHeader((Section) ((Choice) case3.elements(Section.class).get(0)).get(0).get(0));
    assertCorrectFooter((Section) ((Choice) case3.elements(Section.class).get(0)).get(1).get(0));
    assertEquals(1, resolution.getResolution((Choice) case3.elements(Section.class).get(0)));
    Section case4 = (Section) page.getSection().elements(Section.class).get(3);
    assertEquals("first", ((Section) ((Choice) case4.elements(Section.class).get(0)).get(0).get(0)).getId());
    assertCorrectHeader((Section) ((Choice) case4.elements(Section.class).get(0)).get(1).get(0));
    assertEquals("middle", ((Section) ((Choice) case4.elements(Section.class).get(0)).get(2).get(0)).getId());
    assertCorrectFooter((Section) ((Choice) case4.elements(Section.class).get(0)).get(3).get(0));
    assertEquals("last", ((Section) ((Choice) case4.elements(Section.class).get(0)).get(4).get(0)).getId());
    assertEquals(4, resolution.getResolution((Choice) case4.elements(Section.class).get(0)));
    Section case5 = (Section) page.getSection().elements(Section.class).get(4);
    assertEquals(2, ((Choice) case5.elements(Section.class).get(0)).alternatives().size());
    assertCorrectHeader((Section) ((Choice) case5.elements(Section.class).get(0)).get(0).get(0));
    assertEquals("second", ((Section) ((Choice) case5.elements(Section.class).get(0)).get(1).get(0)).getId());
    assertEquals(1, resolution.getResolution((Choice) case5.elements(Section.class).get(0)));
    // This case - a choice inside a choice - makes little sense. It is included as a reminder -
    // what we really want is to be able to include some additional alternatives of a choice,
    // but without any magic. That requires allowing alternative as a top-level tag, or something
    Section case6 = (Section) page.getSection().elements(Section.class).get(5);
    Choice includerChoice = (Choice) case6.elements().get(0);
    Choice includedChoice = (Choice) includerChoice.alternatives().get(0).get(0);
    assertCorrectFooter((Section) includedChoice.alternatives().get(0).get(0));
}
Also used : Choice(com.yahoo.search.pagetemplates.model.Choice) DeterministicResolver(com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver) Section(com.yahoo.search.pagetemplates.model.Section) Resolution(com.yahoo.search.pagetemplates.engine.Resolution)

Example 5 with Section

use of com.yahoo.search.pagetemplates.model.Section 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

Section (com.yahoo.search.pagetemplates.model.Section)5 Choice (com.yahoo.search.pagetemplates.model.Choice)3 Source (com.yahoo.search.pagetemplates.model.Source)3 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)2 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)2 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)1 Renderer (com.yahoo.search.pagetemplates.model.Renderer)1