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));
}
Aggregations