use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class SimpleDocumentProcessorTestCase method requireThatProcessingMultipleOperationsWork.
@Test
public void requireThatProcessingMultipleOperationsWork() {
DocumentType type = new DocumentType("foobar");
type.addField("title", DataType.STRING);
Processing p = getProcessing(new DocumentPut(type, "doc:this:is:a:document"), new DocumentUpdate(type, "doc:this:is:an:update"), new DocumentRemove(new DocumentId("doc:this:is:a:remove")));
DocprocService service = setupDocprocService(new VerySimpleDocumentProcessor());
service.getExecutor().process(p);
assertThat(p.getDocumentOperations().size(), is(3));
assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true));
assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), is("processed"));
assertThat(p.getDocumentOperations().get(1) instanceof DocumentUpdate, is(true));
assertThat(p.getDocumentOperations().get(2) instanceof DocumentRemove, is(true));
assertThat(p.getDocumentOperations().get(2).getId().toString(), is("userdoc:foobar:1234:something"));
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class JsonReaderTestCase method controlBasicFeed.
protected void controlBasicFeed(JsonReader r) {
DocumentOperation d = r.next();
Document doc = ((DocumentPut) d).getDocument();
smokeTestDoc(doc);
d = r.next();
DocumentUpdate update = (DocumentUpdate) d;
checkSimpleArrayAdd(update);
d = r.next();
DocumentRemove remove = (DocumentRemove) d;
assertEquals("smoke", remove.getId().getDocType());
assertNull(r.next());
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class JsonReaderTestCase method testStructUpdate.
@Test
public final void testStructUpdate() throws IOException {
DocumentUpdate put = parseUpdate("{\"update\": \"id:unittest:mirrors:g=test:whee\"," + "\"create\": true," + " \"fields\": { " + "\"skuggsjaa\": {" + "\"assign\": { \"sandra\": \"person\"," + " \"cloud\": \"another person\"}}}}");
assertEquals(1, put.getFieldUpdates().size());
FieldUpdate fu = put.getFieldUpdate(0);
assertEquals(1, fu.getValueUpdates().size());
ValueUpdate vu = fu.getValueUpdate(0);
assertTrue(vu instanceof AssignValueUpdate);
AssignValueUpdate avu = (AssignValueUpdate) vu;
assertTrue(avu.getValue() instanceof Struct);
Struct s = (Struct) avu.getValue();
assertEquals(2, s.getFieldCount());
assertEquals(new StringFieldValue("person"), s.getFieldValue(s.getField("sandra")));
GrowableByteBuffer buf = new GrowableByteBuffer();
DocumentSerializer serializer = DocumentSerializerFactory.createHead(buf);
put.serialize(serializer);
assertEquals(107, buf.position());
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class JsonReaderTestCase method createAssignUpdateWithTensor.
private DocumentUpdate createAssignUpdateWithTensor(String inputTensor, String tensorFieldName) {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("[ { \"update\": \"" + TENSOR_DOC_ID + "\", \"fields\": { \"" + tensorFieldName + "\": {" + "\"assign\": " + (inputTensor != null ? inputTensor : "null") + " } } } ]"));
JsonReader reader = new JsonReader(types, rawDoc, parserFactory);
return (DocumentUpdate) reader.next();
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class JsonReaderTestCase method testUpdateArray.
@Test
public final void testUpdateArray() throws IOException {
DocumentUpdate doc = parseUpdate("{\"update\": \"id:unittest:testarray::whee\"," + " \"fields\": { " + "\"actualarray\": {" + " \"add\": [" + " \"person\"," + " \"another person\"]}}}");
checkSimpleArrayAdd(doc);
}
Aggregations