use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SetValueTestCase method requireThatValueIsSet.
@Test
public void requireThatValueIsSet() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new SetValueExpression(new StringFieldValue("69")).execute(ctx);
assertEquals(new StringFieldValue("69"), ctx.getValue());
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SplitTestCase method requireThatValueIsSplit.
@Test
public void requireThatValueIsSplit() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6;9"));
new SplitExpression(";").execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val.getDataType().equals(DataType.getArray(DataType.STRING)));
assertTrue(val instanceof Array);
Array arr = (Array) val;
assertEquals(new StringFieldValue("6"), arr.get(0));
assertEquals(new StringFieldValue("9"), arr.get(1));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SubstringTestCase method requireThatRangeIsCappedToInput.
@Test
public void requireThatRangeIsCappedToInput() {
assertEquals(new StringFieldValue(""), new SubstringExpression(6, 9).execute(new StringFieldValue("012345")));
assertEquals(new StringFieldValue("345"), new SubstringExpression(3, 9).execute(new StringFieldValue("012345")));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SwitchTestCase method requireThatDefaultExpressionIsExecuted.
@Test
public void requireThatDefaultExpressionIsExecuted() {
Map<String, Expression> cases = new HashMap<>();
cases.put("foo", new StatementExpression(new SetValueExpression(new StringFieldValue("bar")), new SetVarExpression("out")));
Expression defaultExp = new StatementExpression(new SetValueExpression(new StringFieldValue("cox")), new SetVarExpression("out"));
Expression exp = new SwitchExpression(cases, defaultExp);
assertEvaluate(new StringFieldValue("foo"), exp, new StringFieldValue("bar"));
assertEvaluate(new StringFieldValue("baz"), exp, new StringFieldValue("cox"));
assertEvaluate(null, exp, new StringFieldValue("cox"));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class ToDoubleTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6.9")).execute(new ToDoubleExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof DoubleFieldValue);
assertEquals(6.9, ((DoubleFieldValue) val).getDouble(), 1e-6);
}
Aggregations