Search in sources :

Example 1 with SpecialtokensConfig

use of com.yahoo.vespa.configdefinition.SpecialtokensConfig in project vespa by vespa-engine.

the class UserConfigBuilderTest method assertArraysOfStructs.

private void assertArraysOfStructs(Element configRoot) {
    UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger());
    assertFalse(map.isEmpty());
    ConfigDefinitionKey key = new ConfigDefinitionKey(SpecialtokensConfig.CONFIG_DEF_NAME, SpecialtokensConfig.CONFIG_DEF_NAMESPACE);
    assertNotNull(map.get(key));
    SpecialtokensConfig config = createConfig(SpecialtokensConfig.class, map.get(key));
    assertThat(config.tokenlist().size(), is(1));
    assertThat(config.tokenlist().get(0).name(), is("default"));
    assertThat(config.tokenlist().get(0).tokens().size(), is(1));
    assertThat(config.tokenlist().get(0).tokens().get(0).token(), is("dvd+-r"));
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) SpecialtokensConfig(com.yahoo.vespa.configdefinition.SpecialtokensConfig)

Example 2 with SpecialtokensConfig

use of com.yahoo.vespa.configdefinition.SpecialtokensConfig in project vespa by vespa-engine.

the class RewriterFeaturesTestCase method testConvertStringToQTree.

@Test
public final void testConvertStringToQTree() {
    Execution placeholder = new Execution(Context.createContextStub());
    SpecialTokenRegistry tokenRegistry = new SpecialTokenRegistry(new SpecialtokensConfig(new SpecialtokensConfig.Builder().tokenlist(new Tokenlist.Builder().name("default").tokens(new Tokens.Builder().token(ASCII_ELLIPSIS)))));
    placeholder.context().setTokenRegistry(tokenRegistry);
    Query query = new Query();
    query.getModel().setExecution(placeholder);
    Item parsed = RewriterFeatures.convertStringToQTree(query, "a b c " + ASCII_ELLIPSIS);
    assertSame(AndItem.class, parsed.getClass());
    assertEquals(4, ((CompositeItem) parsed).getItemCount());
    assertEquals(ASCII_ELLIPSIS, ((CompositeItem) parsed).getItem(3).toString());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Item(com.yahoo.prelude.query.Item) AndItem(com.yahoo.prelude.query.AndItem) CompositeItem(com.yahoo.prelude.query.CompositeItem) Execution(com.yahoo.search.searchchain.Execution) SpecialTokenRegistry(com.yahoo.prelude.query.parser.SpecialTokenRegistry) Query(com.yahoo.search.Query) SpecialtokensConfig(com.yahoo.vespa.configdefinition.SpecialtokensConfig) Tokenlist(com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist) Tokens(com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist.Tokens) Test(org.junit.Test)

Aggregations

SpecialtokensConfig (com.yahoo.vespa.configdefinition.SpecialtokensConfig)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)1 AndItem (com.yahoo.prelude.query.AndItem)1 CompositeItem (com.yahoo.prelude.query.CompositeItem)1 Item (com.yahoo.prelude.query.Item)1 SpecialTokenRegistry (com.yahoo.prelude.query.parser.SpecialTokenRegistry)1 Query (com.yahoo.search.Query)1 Execution (com.yahoo.search.searchchain.Execution)1 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)1 Tokenlist (com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist)1 Tokens (com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist.Tokens)1 Test (org.junit.Test)1