use of com.yahoo.search.pagetemplates.model.Renderer 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);
}
use of com.yahoo.search.pagetemplates.model.Renderer in project vespa by vespa-engine.
the class TiledTemplateSet method renderSectionContent.
protected void renderSectionContent(HitGroup hit, XMLWriter writer) throws IOException {
if (hit instanceof SectionHitGroup) {
// render additional information
SectionHitGroup sectionGroup = (SectionHitGroup) hit;
for (Source source : sectionGroup.sources()) {
writer.openTag("source").attribute("url", source.getUrl());
renderParameters(source.parameters(), writer);
writer.closeTag();
}
for (Renderer renderer : sectionGroup.renderers()) {
writer.openTag("renderer").attribute("for", renderer.getRendererFor()).attribute("name", renderer.getName());
renderParameters(renderer.parameters(), writer);
writer.closeTag();
}
}
}
Aggregations