use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class NormalizeTestCase method requireThatInputIsNormalized.
@Test
public void requireThatInputIsNormalized() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setLanguage(Language.ENGLISH);
ctx.setValue(new StringFieldValue("b\u00e9yonc\u00e8"));
new NormalizeExpression(new SimpleLinguistics()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("beyonce", ((StringFieldValue) val).getString());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class RandomTestCase method requireThatRandomValueIsSet.
@Test
public void requireThatRandomValueIsSet() {
for (int i = 0; i < 666; ++i) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new RandomExpression(69).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertTrue(((IntegerFieldValue) val).getInteger() < 69);
}
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter 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.vespa.indexinglanguage.SimpleTestAdapter 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