Search in sources :

Example 21 with ValueUpdate

use of com.yahoo.document.update.ValueUpdate in project vespa by vespa-engine.

the class ValueUpdateToDocumentTestCase method requireThatAddIsConverted.

@SuppressWarnings({ "unchecked" })
@Test
public void requireThatAddIsConverted() {
    DocumentType docType = new DocumentType("my_type");
    ArrayDataType arrType = DataType.getArray(DataType.INT);
    Field field = new Field("my_arr", arrType);
    docType.addField(field);
    ValueUpdate update = ValueUpdate.createMap(new IntegerFieldValue(0), ValueUpdate.createAdd(new IntegerFieldValue(6)));
    Document doc = FieldUpdateHelper.newPartialDocument(docType, new DocumentId("doc:foo:1"), field, update);
    assertNotNull(doc);
    FieldValue obj = doc.getFieldValue("my_arr");
    assertTrue(obj instanceof Array);
    Array arr = (Array) obj;
    assertEquals(1, arr.size());
    assertEquals(new IntegerFieldValue(6), arr.get(0));
}
Also used : ValueUpdate(com.yahoo.document.update.ValueUpdate) Test(org.junit.Test)

Aggregations

ValueUpdate (com.yahoo.document.update.ValueUpdate)21 Test (org.junit.Test)16 FieldUpdate (com.yahoo.document.update.FieldUpdate)12 AssignValueUpdate (com.yahoo.document.update.AssignValueUpdate)10 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)8 AddValueUpdate (com.yahoo.document.update.AddValueUpdate)7 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 ArithmeticValueUpdate (com.yahoo.document.update.ArithmeticValueUpdate)5 ClearValueUpdate (com.yahoo.document.update.ClearValueUpdate)5 MapValueUpdate (com.yahoo.document.update.MapValueUpdate)5 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)3 Struct (com.yahoo.document.datatypes.Struct)3 FieldValue (com.yahoo.document.datatypes.FieldValue)2 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)2 DocumentSerializer (com.yahoo.document.serialization.DocumentSerializer)2 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)2 HashMap (java.util.HashMap)2 Tuple2 (com.yahoo.collections.Tuple2)1 ArrayDataType (com.yahoo.document.ArrayDataType)1 CollectionDataType (com.yahoo.document.CollectionDataType)1