Search in sources :

Example 61 with SimpleTestAdapter

use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.

the class GetVarTestCase method requireThatGetVarCanBeUsedToImplementSum.

@Test
public void requireThatGetVarCanBeUsedToImplementSum() throws ParseException {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setOutputValue(null, "in", new StringFieldValue("0;1;2;3;4;5;6;7;8;9"));
    ScriptExpression.fromString("{ 0 | set_var tmp; " + "  input in | split ';' | for_each { to_int + get_var tmp | set_var tmp };" + "  get_var tmp | attribute out; }").execute(ctx);
    FieldValue val = ctx.getInputValue("out");
    assertTrue(val instanceof IntegerFieldValue);
    assertEquals(45, ((IntegerFieldValue) val).getInteger());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 62 with SimpleTestAdapter

use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.

the class ArithmeticTestCase method evaluate.

private static FieldValue evaluate(Expression lhs, Operator op, Expression rhs) {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    new ArithmeticExpression(lhs, op, rhs).execute(ctx);
    return ctx.getValue();
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)

Example 63 with SimpleTestAdapter

use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.

the class Base64DecodeTestCase method requireThatInputIsDecoded.

@Test
public void requireThatInputIsDecoded() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("zcIoHQ"));
    new Base64DecodeExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof LongFieldValue);
    assertEquals(489210573L, ((LongFieldValue) val).getLong());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 64 with SimpleTestAdapter

use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.

the class CatTestCase method evaluate.

private static DataType evaluate(DataType typeA, DataType typeB) {
    SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("a", typeA), new Field("b", typeB));
    VerificationContext ctx = new VerificationContext(adapter);
    new CatExpression(new InputExpression("a"), new InputExpression("b")).verify(ctx);
    return ctx.getValue();
}
Also used : Field(com.yahoo.document.Field) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)

Example 65 with SimpleTestAdapter

use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.

the class CatTestCase method evaluate.

private static FieldValue evaluate(DataType typeA, FieldValue valA, DataType typeB, FieldValue valB) {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter(new Field("a", typeA), new Field("b", typeB)));
    ctx.setOutputValue(null, "a", valA);
    ctx.setOutputValue(null, "b", valB);
    new CatExpression(new InputExpression("a"), new InputExpression("b")).execute(ctx);
    return ctx.getValue();
}
Also used : Field(com.yahoo.document.Field) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)

Aggregations

SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)67 Test (org.junit.Test)59 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)42 FieldValue (com.yahoo.document.datatypes.FieldValue)30 Field (com.yahoo.document.Field)14 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)14 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)7 Array (com.yahoo.document.datatypes.Array)4 StructDataType (com.yahoo.document.StructDataType)3 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)3 Pair (com.yahoo.collections.Pair)1 ArrayDataType (com.yahoo.document.ArrayDataType)1 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)1 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)1 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)1 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)1 StructuredFieldValue (com.yahoo.document.datatypes.StructuredFieldValue)1 WeightedSet (com.yahoo.document.datatypes.WeightedSet)1 AnnotatorConfig (com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1