Search in sources :

Example 1 with SimpleTestAdapter

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

the class ExactTestCase method requireThatValueIsNotChanged.

@Test
public void requireThatValueIsNotChanged() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("FOO"));
    new ExactExpression().execute(ctx);
    assertEquals("FOO", String.valueOf(ctx.getValue()));
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 2 with SimpleTestAdapter

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

the class ExactTestCase method requireThatValueIsAnnotated.

@Test
public void requireThatValueIsAnnotated() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("FOO"));
    new ExactExpression().execute(ctx);
    assertAnnotation(0, 3, new StringFieldValue("foo"), (StringFieldValue) ctx.getValue());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 3 with SimpleTestAdapter

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

the class ForEachTestCase method requireThatEmptyWsetCanBeConverted.

@Test
public void requireThatEmptyWsetCanBeConverted() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new WeightedSet<StringFieldValue>(DataType.getWeightedSet(DataType.STRING)));
    new ForEachExpression(new ToIntegerExpression()).execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof WeightedSet);
    assertEquals(DataType.INT, ((WeightedSet) val).getDataType().getNestedType());
    assertTrue(((WeightedSet) val).isEmpty());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) Test(org.junit.Test)

Example 4 with SimpleTestAdapter

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

the class ForEachTestCase method requireThatWsetCanBeConverted.

@Test
public void requireThatWsetCanBeConverted() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    WeightedSet<StringFieldValue> before = new WeightedSet<>(DataType.getWeightedSet(DataType.STRING));
    before.put(new StringFieldValue("6"), 9);
    before.put(new StringFieldValue("9"), 6);
    ctx.setValue(before);
    new ForEachExpression(new ToIntegerExpression()).execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof WeightedSet);
    WeightedSet after = (WeightedSet) val;
    assertEquals(2, after.size());
    assertEquals(new Integer(9), after.get(new IntegerFieldValue(6)));
    assertEquals(new Integer(6), after.get(new IntegerFieldValue(9)));
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) Test(org.junit.Test)

Example 5 with SimpleTestAdapter

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

the class ForEachTestCase method requireThatArrayWithNullCanBeConverted.

@Test
public void requireThatArrayWithNullCanBeConverted() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    Array<StringFieldValue> arr = new Array<>(DataType.getArray(DataType.STRING));
    arr.add(new StringFieldValue("foo"));
    ctx.setValue(arr);
    new ForEachExpression(SimpleExpression.newConversion(DataType.STRING, DataType.INT).setExecuteValue(null)).execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof Array);
    assertEquals(DataType.INT, ((Array) val).getDataType().getNestedType());
    assertTrue(((Array) val).isEmpty());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) Test(org.junit.Test)

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