use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class SplitTestCase method requireThatEmptyInputProducesEmptyArray.
@Test
public void requireThatEmptyInputProducesEmptyArray() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue(""));
new SplitExpression(";").execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val.getDataType().equals(DataType.getArray(DataType.STRING)));
assertTrue(val instanceof Array);
assertEquals(0, ((Array) val).size());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class SubstringTestCase method requireThatStringIsSliced.
@Test
public void requireThatStringIsSliced() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("666999"));
new SubstringExpression(2, 4).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("69", ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ExecutionContextTestCase method requireThatVariablesCanBeSet.
@Test
public void requireThatVariablesCanBeSet() {
ExecutionContext ctx = new ExecutionContext();
FieldValue val = new StringFieldValue("foo");
ctx.setVariable("foo", val);
assertSame(val, ctx.getVariable("foo"));
}
use of com.yahoo.document.datatypes.FieldValue 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.document.datatypes.FieldValue 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