Search in sources :

Example 26 with StringFieldValue

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

the class HexDecodeTestCase method requireInputIsDecoded.

@Test
public void requireInputIsDecoded() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("1d28c2cd"));
    new HexDecodeExpression().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 27 with StringFieldValue

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

the class HexDecodeTestCase method requireThatIllegalInputThrows.

@Test
public void requireThatIllegalInputThrows() {
    try {
        new HexDecodeExpression().execute(new StringFieldValue("???"));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Illegal hex value '???'.", e.getMessage());
    }
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 28 with StringFieldValue

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

the class HostNameTestCase method requireThatHostnameIsSet.

@Test
public void requireThatHostnameIsSet() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    new HostNameExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof StringFieldValue);
    assertEquals(HostNameExpression.normalizeHostName(getDefaults().vespaHostname()), ((StringFieldValue) val).getString());
}
Also used : 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 29 with StringFieldValue

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

the class JoinTestCase method requireThatValueIsJoined.

@Test
public void requireThatValueIsJoined() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    Array<StringFieldValue> arr = new Array<>(DataType.getArray(DataType.STRING));
    arr.add(new StringFieldValue("6"));
    arr.add(new StringFieldValue("9"));
    ctx.setValue(arr);
    new JoinExpression(";").execute(ctx);
    assertEquals(new StringFieldValue("6;9"), ctx.getValue());
}
Also used : Array(com.yahoo.document.datatypes.Array) SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Test(org.junit.Test)

Example 30 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue 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());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) 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)

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