use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class TokenizeTestCase method requireThatValueIsAnnotated.
@Test
public void requireThatValueIsAnnotated() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("foo"));
new TokenizeExpression(new SimpleLinguistics(), new AnnotatorConfig()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertNotNull(((StringFieldValue) val).getSpanTree(SpanTrees.LINGUISTICS));
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ToArrayTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToArrayExpression());
FieldValue val = ctx.getValue();
assertEquals(Array.class, val.getClass());
Array arr = (Array) val;
ArrayDataType type = arr.getDataType();
assertEquals(DataType.STRING, type.getNestedType());
assertEquals(1, arr.size());
assertEquals(new StringFieldValue("69"), arr.get(0));
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ToPositionTestCase method requireThatPositionIsParsed.
@Test
public void requireThatPositionIsParsed() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6;9")).execute(new ToPositionExpression());
FieldValue out = ctx.getValue();
assertTrue(out instanceof StructuredFieldValue);
assertEquals(PositionDataType.INSTANCE, out.getDataType());
FieldValue val = ((StructuredFieldValue) out).getFieldValue("x");
assertTrue(val instanceof IntegerFieldValue);
assertEquals(6, ((IntegerFieldValue) val).getInteger());
val = ((StructuredFieldValue) out).getFieldValue("y");
assertTrue(val instanceof IntegerFieldValue);
assertEquals(9, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ToByteTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToByteExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof ByteFieldValue);
assertEquals(69, ((ByteFieldValue) val).getByte());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ToFloatTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6.9f")).execute(new ToFloatExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof FloatFieldValue);
assertEquals(6.9f, ((FloatFieldValue) val).getFloat(), 1e-6);
}
Aggregations