Search in sources :

Example 26 with SimpleTestAdapter

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

the class ScriptTestCase method requireThatInputValueIsAvailableToAllStatements.

@Test
public void requireThatInputValueIsAvailableToAllStatements() {
    SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("out-1", DataType.INT), new Field("out-2", DataType.INT));
    newStatement(new SetValueExpression(new IntegerFieldValue(69)), newScript(newStatement(new AttributeExpression("out-1"), new AttributeExpression("out-2")))).execute(adapter);
    assertEquals(new IntegerFieldValue(69), adapter.getInputValue("out-1"));
    assertEquals(new IntegerFieldValue(69), adapter.getInputValue("out-2"));
}
Also used : Field(com.yahoo.document.Field) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 27 with SimpleTestAdapter

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

the class ScriptTestCase method requireThatVariablesAreAvailableOutsideScript.

@Test
public void requireThatVariablesAreAvailableOutsideScript() {
    SimpleTestAdapter adapter = new SimpleTestAdapter(new Field("out", DataType.INT));
    newStatement(newScript(newStatement(new SetValueExpression(new IntegerFieldValue(69)), new SetVarExpression("tmp"))), new GetVarExpression("tmp"), new AttributeExpression("out")).execute(adapter);
    assertEquals(new IntegerFieldValue(69), adapter.getInputValue("out"));
}
Also used : Field(com.yahoo.document.Field) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 28 with SimpleTestAdapter

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

the class SetLanguageTestCase method testSettingUnknown.

@Test
public void testSettingUnknown() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("unknown"));
    new SetLanguageExpression().execute(ctx);
    assertEquals(Language.UNKNOWN, ctx.getLanguage());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 29 with SimpleTestAdapter

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

the class SetVarTestCase method requireThatSymbolIsWritten.

@Test
public void requireThatSymbolIsWritten() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new IntegerFieldValue(69));
    new SetVarExpression("out").execute(ctx);
    FieldValue val = ctx.getVariable("out");
    assertTrue(val instanceof IntegerFieldValue);
    assertEquals(69, ((IntegerFieldValue) val).getInteger());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 30 with SimpleTestAdapter

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

the class ToStringTestCase method requireThatValueIsConverted.

@Test
public void requireThatValueIsConverted() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new IntegerFieldValue(69)).execute(new ToStringExpression());
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof StringFieldValue);
    assertEquals("69", ((StringFieldValue) val).getString());
}
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)

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