Search in sources :

Example 1 with PageTemplateRegistry

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"));
}
Also used : PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry) PageTemplateXMLReader(com.yahoo.search.pagetemplates.config.PageTemplateXMLReader)

Example 2 with PageTemplateRegistry

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());
    }
}
Also used : PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry) PageTemplateXMLReader(com.yahoo.search.pagetemplates.config.PageTemplateXMLReader)

Example 3 with PageTemplateRegistry

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;
}
Also used : PageTemplate(com.yahoo.search.pagetemplates.PageTemplate) PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry) com.yahoo.search.intent.model(com.yahoo.search.intent.model) PageElement(com.yahoo.search.pagetemplates.model.PageElement) ComponentId(com.yahoo.component.ComponentId)

Example 4 with PageTemplateRegistry

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;
}
Also used : PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry)

Example 5 with PageTemplateRegistry

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"));
}
Also used : PageTemplateRegistry(com.yahoo.search.pagetemplates.PageTemplateRegistry) PageTemplateXMLReader(com.yahoo.search.pagetemplates.config.PageTemplateXMLReader)

Aggregations

PageTemplateRegistry (com.yahoo.search.pagetemplates.PageTemplateRegistry)8 PageTemplate (com.yahoo.search.pagetemplates.PageTemplate)3 PageTemplateXMLReader (com.yahoo.search.pagetemplates.config.PageTemplateXMLReader)3 Query (com.yahoo.search.Query)2 PageTemplateSearcher (com.yahoo.search.pagetemplates.PageTemplateSearcher)2 Execution (com.yahoo.search.searchchain.Execution)2 ComponentId (com.yahoo.component.ComponentId)1 com.yahoo.search.intent.model (com.yahoo.search.intent.model)1 PageTemplatesConfig (com.yahoo.search.pagetemplates.PageTemplatesConfig)1 PageElement (com.yahoo.search.pagetemplates.model.PageElement)1