use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class PageTemplateXMLReadingTestCase method testExamples.
public void testExamples() {
PageTemplateRegistry registry = new PageTemplateXMLReader().read(root + "examples");
assertCorrectSerp(registry.getComponent("serp"));
assertCorrectSlottingSerp(registry.getComponent("slottingSerp"));
assertCorrectRichSerp(registry.getComponent("richSerp"));
assertCorrectRicherSerp(registry.getComponent("richerSerp"));
assertCorrectIncluder(registry.getComponent("includer"));
assertCorrectGeneric(registry.getComponent("generic"));
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class PageTemplateXMLReadingTestCase method testInvalidFilename.
public void testInvalidFilename() {
try {
PageTemplateRegistry registry = new PageTemplateXMLReader().read(root + "examples/invalidfilename");
assertEquals(0, registry.allComponents().size());
fail("Should have caused an exception");
} catch (IllegalArgumentException e) {
assertEquals("The file name of page template 'notinvalid' must be 'notinvalid.xml' but was 'invalid.xml'", e.getMessage());
}
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class PageTemplateSearcherTestCase method createPageTemplateRegistry.
private PageTemplateRegistry createPageTemplateRegistry() {
PageTemplateRegistry registry = new PageTemplateRegistry();
PageTemplate twoSources = new PageTemplate(new ComponentId("default"));
twoSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
twoSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
registry.register(twoSources);
PageTemplate oneSource = new PageTemplate(new ComponentId("oneSource"));
oneSource.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
registry.register(oneSource);
PageTemplate threeSources = new PageTemplate(new ComponentId("threeSources"));
threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
threeSources.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source3"));
registry.register(threeSources);
PageTemplate twoSourcesAndAny = new PageTemplate(new ComponentId("twoSourcesAndAny"));
twoSourcesAndAny.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source1"));
twoSourcesAndAny.getSection().elements().add(new com.yahoo.search.pagetemplates.model.Source("source2"));
twoSourcesAndAny.getSection().elements().add(com.yahoo.search.pagetemplates.model.Source.any);
registry.register(twoSourcesAndAny);
PageTemplate anySource = new PageTemplate(new ComponentId("anySource"));
anySource.getSection().elements().add(com.yahoo.search.pagetemplates.model.Source.any);
registry.register(anySource);
PageTemplate choiceOfSources = new PageTemplate(new ComponentId("choiceOfSources"));
List<PageElement> alternatives = new ArrayList<>();
alternatives.add(new com.yahoo.search.pagetemplates.model.Source("source1"));
alternatives.add(new com.yahoo.search.pagetemplates.model.Source("source2"));
choiceOfSources.getSection().elements().add(Choice.createSingletons(alternatives));
registry.register(choiceOfSources);
registry.freeze();
return registry;
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class PageTemplateXMLReader method read.
/**
* Reads all page template xml files in a given list of readers. This is called from the Vespa configuration model.
*
* @param validateReaderNames should be set to true if the readers were created by files, not otherwise
* @throws RuntimeException if <code>directory</code> is not a readable directory, or if there is some error in the XML
*/
public PageTemplateRegistry read(List<NamedReader> pageReaders, boolean validateReaderNames) {
// Initialize state
registry = new PageTemplateRegistry();
// Phase 1
pageElementsByPageId = createPages(pageReaders, validateReaderNames);
// Phase 2
readPages();
return registry;
}
use of com.yahoo.search.pagetemplates.PageTemplateRegistry in project vespa by vespa-engine.
the class MapPageTemplateXMLReadingTestCase method testMap1.
public void testMap1() {
PageTemplateRegistry registry = new PageTemplateXMLReader().read(root);
assertCorrectMap1(registry.getComponent("map1"));
}
Aggregations