use of com.yahoo.vespa.indexinglanguage.SimpleDocumentAdapter in project vespa by vespa-engine.
the class GetFieldTestCase method requireThatStructFieldsCanBeRead.
@Test
public void requireThatStructFieldsCanBeRead() {
DataType barType = DataType.STRING;
FieldValue bar = barType.createFieldValue("bar");
StructDataType fooType = new StructDataType("my_struct");
fooType.addField(new Field("bar", barType));
Struct foo = new Struct(fooType);
foo.setFieldValue("bar", bar);
DocumentType docType = new DocumentType("my_doc");
docType.addField("foo", fooType);
Document doc = new Document(docType, "doc:scheme:");
doc.setFieldValue("foo", foo);
ExecutionContext ctx = new ExecutionContext(new SimpleDocumentAdapter(doc));
assertEquals(bar, new StatementExpression(new InputExpression("foo"), new GetFieldExpression("bar")).execute(ctx));
}
use of com.yahoo.vespa.indexinglanguage.SimpleDocumentAdapter in project vespa by vespa-engine.
the class InputTestCase method requireThatStructFieldsCanBeRead.
@Test
public void requireThatStructFieldsCanBeRead() {
DataType barType = DataType.STRING;
FieldValue bar = barType.createFieldValue("bar");
StructDataType fooType = new StructDataType("my_struct");
fooType.addField(new Field("bar", barType));
Struct foo = new Struct(fooType);
foo.setFieldValue("bar", bar);
DocumentType docType = new DocumentType("my_doc");
docType.addField("foo", fooType);
Document doc = new Document(docType, "doc:scheme:");
doc.setFieldValue("foo", foo);
ExecutionContext ctx = new ExecutionContext(new SimpleDocumentAdapter(doc));
assertEquals(foo, new InputExpression("foo").execute(ctx));
assertEquals(bar, new InputExpression("foo.bar").execute(ctx));
}
Aggregations