use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class StatementTestCase method requireThatStatementIsExecuted.
@Test
public void requireThatStatementIsExecuted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
StatementExpression statement = newStatement(new SetValueExpression(new IntegerFieldValue(69)));
newStatement(statement).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 SelectInputTestCase method assertSelect.
private static void assertSelect(List<String> inputField, List<String> availableFields, String expected) {
SimpleTestAdapter adapter = new SimpleTestAdapter();
ExecutionContext ctx = new ExecutionContext(adapter);
for (String fieldName : availableFields) {
adapter.createField(new Field(fieldName, DataType.STRING));
ctx.setOutputValue(null, fieldName, new StringFieldValue(fieldName));
}
List<Pair<String, Expression>> cases = new LinkedList<>();
for (String fieldName : inputField) {
cases.add(new Pair<String, Expression>(fieldName, new SetVarExpression("out")));
}
new SelectInputExpression(cases).execute(ctx);
assertEquals(expected != null ? new StringFieldValue(expected) : null, ctx.getVariable("out"));
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class SelectInputTestCase method requireThatExpressionCanBeVerified.
@Test
public void requireThatExpressionCanBeVerified() {
SimpleTestAdapter adapter = new SimpleTestAdapter();
adapter.createField(new Field("my_int", DataType.INT));
adapter.createField(new Field("my_str", DataType.STRING));
Expression exp = newSelectInput(new AttributeExpression("my_int"), "my_int");
assertVerify(adapter, null, exp);
assertVerify(adapter, DataType.INT, exp);
assertVerify(adapter, DataType.STRING, exp);
assertVerifyThrows(adapter, newSelectInput(new AttributeExpression("my_int"), "my_str"), "Can not assign string to field 'my_int' which is int.");
assertVerifyThrows(adapter, newSelectInput(new AttributeExpression("my_int"), "my_unknown"), "Field 'my_unknown' not found.");
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class SplitTestCase method requireThatNullInputProducesNullOutput.
@Test
public void requireThatNullInputProducesNullOutput() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new SplitExpression(";").execute(ctx);
assertNull(ctx.getValue());
}
Aggregations