use of com.yahoo.vespa.indexinglanguage.UpdateAdapter in project vespa by vespa-engine.
the class GuardTestCase method requireThatLanguageCanBeSetByUpdate.
@Test
public void requireThatLanguageCanBeSetByUpdate() throws ParseException {
DocumentType docType = new DocumentType("my_input");
docType.addField(new Field("my_str", DataType.STRING));
DocumentUpdate docUpdate = new DocumentUpdate(docType, "doc:scheme:");
docUpdate.addFieldUpdate(FieldUpdate.createAssign(docType.getField("my_str"), new StringFieldValue("foo")));
SimpleAdapterFactory factory = new SimpleAdapterFactory();
List<UpdateAdapter> lst = factory.newUpdateAdapterList(docUpdate);
assertEquals(1, lst.size());
ExecutionContext ctx = new ExecutionContext(lst.get(0));
Expression.fromString("guard { 'en' | set_language }").execute(ctx);
assertEquals(Language.ENGLISH, ctx.getLanguage());
}
Aggregations