Search in sources :

Example 31 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue 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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 32 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue 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));
}
Also used : Array(com.yahoo.document.datatypes.Array) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) Test(org.junit.Test)

Example 33 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class SubstringTestCase method requireThatRangeIsCappedToInput.

@Test
public void requireThatRangeIsCappedToInput() {
    assertEquals(new StringFieldValue(""), new SubstringExpression(6, 9).execute(new StringFieldValue("012345")));
    assertEquals(new StringFieldValue("345"), new SubstringExpression(3, 9).execute(new StringFieldValue("012345")));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 34 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class SwitchTestCase method requireThatDefaultExpressionIsExecuted.

@Test
public void requireThatDefaultExpressionIsExecuted() {
    Map<String, Expression> cases = new HashMap<>();
    cases.put("foo", new StatementExpression(new SetValueExpression(new StringFieldValue("bar")), new SetVarExpression("out")));
    Expression defaultExp = new StatementExpression(new SetValueExpression(new StringFieldValue("cox")), new SetVarExpression("out"));
    Expression exp = new SwitchExpression(cases, defaultExp);
    assertEvaluate(new StringFieldValue("foo"), exp, new StringFieldValue("bar"));
    assertEvaluate(new StringFieldValue("baz"), exp, new StringFieldValue("cox"));
    assertEvaluate(null, exp, new StringFieldValue("cox"));
}
Also used : HashMap(java.util.HashMap) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 35 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue 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);
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DoubleFieldValue(com.yahoo.document.datatypes.DoubleFieldValue) DoubleFieldValue(com.yahoo.document.datatypes.DoubleFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) Test(org.junit.Test)

Aggregations

StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)210 Test (org.junit.Test)136 FieldValue (com.yahoo.document.datatypes.FieldValue)49 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)40 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)37 Document (com.yahoo.document.Document)30 Array (com.yahoo.document.datatypes.Array)25 DocumentType (com.yahoo.document.DocumentType)21 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)21 Struct (com.yahoo.document.datatypes.Struct)21 DocumentPut (com.yahoo.document.DocumentPut)20 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)20 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)18 SpanTree (com.yahoo.document.annotation.SpanTree)15 FieldUpdate (com.yahoo.document.update.FieldUpdate)15 DocumentUpdate (com.yahoo.document.DocumentUpdate)12 Field (com.yahoo.document.Field)12 Annotation (com.yahoo.document.annotation.Annotation)12 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)12 HashMap (java.util.HashMap)12