use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class DocumentOperationMessageV3 method newUpdateMessage.
static DocumentOperationMessageV3 newUpdateMessage(VespaXMLFeedReader.Operation op, String operationId) {
DocumentUpdate update = op.getDocumentUpdate();
update.setCondition(op.getCondition());
Message msg = new UpdateDocumentMessage(update);
String id = (operationId == null) ? update.getId().toString() : operationId;
return new DocumentOperationMessageV3(id, msg);
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class Feeder method newUpdateMessage.
private Tuple2<String, Message> newUpdateMessage(Operation op, String operationId) {
DocumentUpdate update = op.getDocumentUpdate();
update.setCondition(op.getCondition());
Message msg = new UpdateDocumentMessage(update);
String id = (operationId == null) ? update.getId().toString() : operationId;
return new Tuple2<>(id, msg);
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class VespaFeederTestCase method feedFile.
@Test
public void feedFile() throws Exception {
FeedFixture f = new FeedFixture();
Arguments arguments = new Arguments("--file src/test/files/myfeed.xml --priority LOW_1".split(" "), f.sessionFactory);
new VespaFeeder(arguments, f.typeManager).parseFiles(System.in, f.printStream);
assertEquals(3, f.sessionFactory.messages.size());
assertEquals(DocumentProtocol.Priority.LOW_1, ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getPriority());
assertEquals("doc:test:foo", ((PutDocumentMessage) f.sessionFactory.messages.get(0)).getDocumentPut().getDocument().getId().toString());
DocumentUpdate update = ((UpdateDocumentMessage) f.sessionFactory.messages.get(1)).getDocumentUpdate();
assertEquals("doc:test:foo", update.getId().toString());
assertFalse(update.getCreateIfNonExistent());
assertEquals("doc:test:foo", ((RemoveDocumentMessage) f.sessionFactory.messages.get(2)).getDocumentId().toString());
assertTrue(f.outputStream.toString().contains("Messages sent to vespa"));
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class IndexingProcessorTestCase method requireThatEmptyDocumentUpdateOutputDoesNotThrow.
@Test
public void requireThatEmptyDocumentUpdateOutputDoesNotThrow() {
DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
Processing proc = new Processing();
proc.getDocumentOperations().add(input);
indexer.process(proc);
assertEquals(0, proc.getDocumentOperations().size());
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class IndexingProcessorTestCase method requireThatIndexerProcessesUpdates.
@Test
public void requireThatIndexerProcessesUpdates() {
DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("isbn"), new StringFieldValue("isbnmarker")));
input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("artist"), new StringFieldValue("69")));
DocumentOperation output = process(input);
assertTrue(output instanceof DocumentUpdate);
DocumentUpdate docUpdate = (DocumentUpdate) output;
assertEquals(3, docUpdate.getFieldUpdates().size());
{
FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(0);
assertEquals("song", fieldUpdate.getField().getName());
assertEquals(1, fieldUpdate.getValueUpdates().size());
ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
assertTrue(valueUpdate instanceof AssignValueUpdate);
assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
fieldUpdate = docUpdate.getFieldUpdate(1);
assertEquals("title", fieldUpdate.getField().getName());
assertEquals(1, fieldUpdate.getValueUpdates().size());
valueUpdate = fieldUpdate.getValueUpdate(0);
assertTrue(valueUpdate instanceof AssignValueUpdate);
assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
}
{
FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(1);
ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
assertEquals("title", fieldUpdate.getField().getName());
assertTrue(valueUpdate instanceof AssignValueUpdate);
assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
}
{
FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(2);
ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
assertEquals("isbn", fieldUpdate.getField().getName());
assertTrue(valueUpdate instanceof AssignValueUpdate);
assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
}
}
Aggregations