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));
}
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());
}
Aggregations