use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class LowerCaseTestCase method requireThatStringIsLowerCased.
@Test
public void requireThatStringIsLowerCased() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("FOO"));
new LowerCaseExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("foo", ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class SimpleDocumentAdapterTestCase method requireThatStructFieldsCanBeAccessed.
@Test
public void requireThatStructFieldsCanBeAccessed() {
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);
DocumentAdapter adapter = new SimpleDocumentAdapter(doc);
assertEquals(fooType, adapter.getInputType(null, "foo"));
assertEquals(foo, adapter.getInputValue("foo"));
assertEquals(barType, adapter.getInputType(null, "foo.bar"));
assertEquals(bar, adapter.getInputValue("foo.bar"));
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class HexDecodeTestCase method requireInputIsDecoded.
@Test
public void requireInputIsDecoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("1d28c2cd"));
new HexDecodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof LongFieldValue);
assertEquals(489210573L, ((LongFieldValue) val).getLong());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class HostNameTestCase method requireThatHostnameIsSet.
@Test
public void requireThatHostnameIsSet() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new HostNameExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals(HostNameExpression.normalizeHostName(getDefaults().vespaHostname()), ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class MathResolverTestCase method evaluate.
private static int evaluate(Expression exp) {
FieldValue val = new ExecutionContext(new SimpleTestAdapter()).execute(exp).getValue();
assertTrue(val instanceof IntegerFieldValue);
return ((IntegerFieldValue) val).getInteger();
}
Aggregations