use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class SourceParametersTestCase method testSourceParametersWithSourcesDeterminedByParameter.
public void testSourceParametersWithSourcesDeterminedByParameter() {
// Create the page template
PageTemplateRegistry pageTemplateRegistry = new PageTemplateRegistry();
PageTemplate page = importPage("SourceParameters.xml");
pageTemplateRegistry.register(page);
PageTemplateSearcher s = new PageTemplateSearcher(pageTemplateRegistry);
Query query = new Query("?query=foo&page.id=SourceParameters&model.sources=source1,source3&page.resolver=native.deterministic");
new Execution(s, Execution.Context.createContextStub()).search(query);
assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
assertEquals("source3p1Value", query.properties().get("source.source3.p1"));
assertEquals("We get the correct number of parameters", 3, query.properties().listProperties("source").size());
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class SourceParametersTestCase method testSourceParametersWithSourcesDeterminedByTemplate.
public void testSourceParametersWithSourcesDeterminedByTemplate() {
// Create the page template
PageTemplateRegistry pageTemplateRegistry = new PageTemplateRegistry();
PageTemplate page = importPage("SourceParameters.xml");
pageTemplateRegistry.register(page);
PageTemplateSearcher s = new PageTemplateSearcher(pageTemplateRegistry);
Query query = new Query("?query=foo&page.id=SourceParameters&page.resolver=native.deterministic");
new Execution(s, Execution.Context.createContextStub()).search(query);
assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
assertEquals("source1p1Value", query.properties().get("source.source1.p1"));
assertEquals("source2p1Value", query.properties().get("source.source2.p1"));
assertEquals("source2p3Value", query.properties().get("source.source2.p3"));
assertEquals("source3p1Value", query.properties().get("source.source3.p1"));
assertEquals("We get the correct number of parameters", 5, query.properties().listProperties("source").size());
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class PageTemplateXMLReadingTestCase method testConfigReading.
public void testConfigReading() {
PageTemplatesConfig config = new PageTemplatesConfig(new PageTemplatesConfig.Builder().page("<page id=\"slottingSerp\" layout=\"mainAndRight\">\n <section layout=\"column\" region=\"main\" source=\"*\" order=\"-[rank]\"/>\n <section layout=\"column\" region=\"right\" source=\"ads\"/>\n</page>\n").page("<page id=\"richSerp\" layout=\"mainAndRight\">\n <section layout=\"row\" region=\"main\">\n <section layout=\"column\" description=\"left main pane\">\n <section layout=\"row\" max=\"5\" description=\"Bar of images, from one of two possible sources\">\n <choice method=\"annealing\">\n <source name=\"images\"/>\n <source name=\"flickr\"/>\n </choice>\n </section>\n <section max=\"1\" source=\"local map video ticker weather\" description=\"A single relevant graphically rich element\"/>\n <section order=\"-[rank]\" max=\"10\" source=\"web news\" description=\"Various kinds of traditional search results\"/>\n </section>\n <section layout=\"column\" order=\"[source]\" source=\"answers blogs twitter\" description=\"right main pane, ugc stuff, grouped by source\"/>\n </section>\n <section layout=\"column\" source=\"ads\" region=\"right\"/>\n</page>\n").page("<page id=\"footer\">\n <section layout=\"row\" source=\"popularSearches\"/>\n <section id=\"extraFooter\" layout=\"row\" source=\"topArticles\"/>\n</page>\n").page("<page id=\"richerSerp\" layout=\"column\">\n <include idref=\"header\"/>\n <section layout=\"mainAndRight\">\n <section layout=\"row\" region=\"main\">\n <section layout=\"column\" description=\"left main pane\">\n <choice>\n <alternative>\n <section layout=\"row\" max=\"5\" description=\"Bar of images, from one of two possible sources\">\n <choice>\n <source name=\"images\"/>\n <alternative>\n <source name=\"flickr\">\n <renderer name=\"mouseOverImage\"/>\n </source>\n <source name=\"twitpic\">\n <choice>\n <renderer name=\"mouseOverImage\">\n <parameter name=\"hovertime\">5</parameter>\n <parameter name=\"borderColor\">#ff00ff</parameter>\n </renderer>\n <renderer name=\"regularImage\"/>\n </choice>\n <parameter name=\"filter\">origin=twitter</parameter>\n </source>\n </alternative>\n </choice>\n <choice>\n <renderer name=\"regularImageBox\"/>\n <renderer name=\"newImageBox\"/>\n </choice>\n </section>\n <section max=\"1\" source=\"local map video ticker weather\" description=\"A single relevant graphically rich element\"/>\n </alternative>\n <section order=\"[source]\" max=\"10\" source=\"web news\" description=\"Various kinds of traditional search results\"/>\n </choice>\n </section>\n <section layout=\"column\" order=\"[source]\" source=\"answers blogs twitter\" description=\"right main pane, ugc stuff, grouped by source\"/>\n </section>\n <section layout=\"column\" source=\"ads\" region=\"right\" order=\"-[rank] clickProbability\">\n <renderer name=\"newAdBox\"/>\n </section>\n </section>\n <include idref=\"footer\"/>\n</page>\n").page("<page id=\"header\">\n <section layout=\"row\">\n <section source=\"global\"/>\n <section source=\"notifications\"/>\n </section>\n</page>\n"));
PageTemplateRegistry registry = PageTemplateConfigurer.toRegistry(config);
assertCorrectSlottingSerp(registry.getComponent("slottingSerp"));
assertCorrectRichSerp(registry.getComponent("richSerp"));
assertCorrectRicherSerp(registry.getComponent("richerSerp"));
}
Aggregations