use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ForEachTestCase method requireThatEachTokenIsExecutedSeparately.
@Test
public void requireThatEachTokenIsExecutedSeparately() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
Array<StringFieldValue> arr = new Array<>(DataType.getArray(DataType.STRING));
arr.add(new StringFieldValue("6"));
arr.add(new StringFieldValue("9"));
ctx.setValue(arr);
MyCollector exp = new MyCollector();
new ForEachExpression(exp).execute(ctx);
assertEquals(2, exp.lst.size());
FieldValue val = exp.lst.get(0);
assertTrue(val instanceof StringFieldValue);
assertEquals("6", ((StringFieldValue) val).getString());
val = exp.lst.get(1);
assertTrue(val instanceof StringFieldValue);
assertEquals("9", ((StringFieldValue) val).getString());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class GetVarTestCase method requireThatSymbolIsRead.
@Test
public void requireThatSymbolIsRead() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setVariable("in", new IntegerFieldValue(69));
new GetVarExpression("in").execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertEquals(69, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class EchoTestCase method requireThatValueIsEchoed.
@Test
public void requireThatValueIsEchoed() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69"));
new EchoExpression(new PrintStream(out)).execute(ctx);
assertEquals("69" + System.getProperty("line.separator"), out.toString());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class HexEncodeTestCase method requireThatInputIsEncoded.
@Test
public void requireThatInputIsEncoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new LongFieldValue(489210573L));
new HexEncodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("1d28c2cd", ((StringFieldValue) val).getString());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class IfThenTestCase method evaluateIfThen.
private static boolean evaluateIfThen(FieldValue lhs, Comparator cmp, FieldValue rhs) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new StatementExpression(new SetValueExpression(new IntegerFieldValue(1)), new IfThenExpression(new SetValueExpression(lhs), cmp, new SetValueExpression(rhs), new SetVarExpression("true"), new SetVarExpression("false"))).execute(ctx);
return ctx.getVariable("true") != null;
}
Aggregations