use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class DocumentScriptTestCase method processPathUpdate.
private static ValueUpdate<?> processPathUpdate(FieldValue fieldValue) {
DocumentType docType = new DocumentType("myDocumentType");
docType.addField("myField", fieldValue.getDataType());
DocumentUpdate update = new DocumentUpdate(docType, "doc:scheme:");
update.addFieldPathUpdate(new AssignFieldPathUpdate(docType, "myField", fieldValue));
update = newScript(docType).execute(ADAPTER_FACTORY, update);
return update.getFieldUpdate("myField").getValueUpdate(0);
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class JsonFeedReader method read.
@Override
public void read(Operation operation) throws Exception {
DocumentOperation documentOperation = reader.next();
if (documentOperation == null) {
stream.close();
operation.setInvalid();
return;
}
if (documentOperation instanceof DocumentUpdate) {
operation.setDocumentUpdate((DocumentUpdate) documentOperation);
} else if (documentOperation instanceof DocumentRemove) {
operation.setRemove(documentOperation.getId());
} else if (documentOperation instanceof DocumentPut) {
operation.setDocument(((DocumentPut) documentOperation).getDocument());
} else {
throw new IllegalStateException("Got unknown class from JSON reader: " + documentOperation.getClass().getName());
}
operation.setCondition(documentOperation.getCondition());
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class VespaFeederTestCase method requireThatCreateIfNonExistentArgumentIsUsed.
@Test
public void requireThatCreateIfNonExistentArgumentIsUsed() throws Exception {
FeedFixture f = new FeedFixture();
Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --create-if-non-existent".split(" "), f.sessionFactory);
new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
assertEquals(3, f.sessionFactory.messages.size());
DocumentUpdate update = ((UpdateDocumentMessage) f.sessionFactory.messages.get(1)).getDocumentUpdate();
assertTrue(update.getCreateIfNonExistent());
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class VespaFeederTestCase method assertJsonFeedState.
protected void assertJsonFeedState(FeedFixture feedFixture) {
assertEquals(3, feedFixture.sessionFactory.messages.size());
assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage) feedFixture.sessionFactory.messages.get(0)).getPriority());
assertEquals("id:test:news::foo", ((PutDocumentMessage) feedFixture.sessionFactory.messages.get(0)).getDocumentPut().getDocument().getId().toString());
DocumentUpdate update = ((UpdateDocumentMessage) feedFixture.sessionFactory.messages.get(1)).getDocumentUpdate();
assertEquals("id:test:news::foo", update.getId().toString());
assertFalse(update.getCreateIfNonExistent());
assertEquals("id:test:news::foo", ((RemoveDocumentMessage) feedFixture.sessionFactory.messages.get(2)).getDocumentId().toString());
assertTrue(feedFixture.outputStream.toString().contains("Messages sent to vespa"));
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class IndexingProcessorTestCase method requireThatIndexerForwardsUpdatesOfUnknownType.
@Test
public void requireThatIndexerForwardsUpdatesOfUnknownType() {
DocumentUpdate input = new DocumentUpdate(new DocumentType("unknown"), "doc:scheme:");
DocumentOperation output = process(input);
assertSame(input, output);
}
Aggregations