use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ToIntegerTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToIntegerExpression());
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 ToWsetTestCase method assertConvert.
private static void assertConvert(boolean createIfNonExistent, boolean removeIfZero) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToWsetExpression(createIfNonExistent, removeIfZero));
FieldValue val = ctx.getValue();
assertEquals(WeightedSet.class, val.getClass());
WeightedSet wset = (WeightedSet) val;
WeightedSetDataType type = wset.getDataType();
assertEquals(DataType.STRING, type.getNestedType());
assertEquals(createIfNonExistent, type.createIfNonExistent());
assertEquals(removeIfZero, type.removeIfZero());
assertEquals(1, wset.size());
assertEquals(Integer.valueOf(1), wset.get(new StringFieldValue("69")));
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class TrimTestCase method requireThatStringIsTrimmed.
@Test
public void requireThatStringIsTrimmed() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue(" 69 ")).execute(new TrimExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("69", ((StringFieldValue) val).getString());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class NowTestCase method requireThatCurrentTimeIsSet.
@Test
public void requireThatCurrentTimeIsSet() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new NowExpression(new MyTimer()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof LongFieldValue);
assertEquals(69L, ((LongFieldValue) val).getLong());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class OutputAssert method assertExecute.
public static void assertExecute(OutputExpression exp) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter(new Field(exp.getFieldName(), DataType.STRING)));
ctx.setValue(new StringFieldValue("69"));
ctx.execute(exp);
FieldValue out = ctx.getInputValue(exp.getFieldName());
assertTrue(out instanceof StringFieldValue);
assertEquals("69", ((StringFieldValue) out).getString());
}
Aggregations