use of com.yahoo.docproc.proxy.ProxyDocument in project vespa by vespa-engine.
the class DocumentGenPluginTest method testConcreteProxyDoc.
@Test
public void testConcreteProxyDoc() {
Book book = getBook();
Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("t", "title");
fieldMap.put("a", "author");
fieldMap.put("i", "isbn");
fieldMap.put("y", "year");
DocumentProcessor dp = new BookProcessor();
ProxyDocument proxiedBook = new ProxyDocument(dp, book, fieldMap);
dp.process(Processing.of(new DocumentPut(proxiedBook)));
assertEquals(proxiedBook.getFieldValue("title").getWrappedValue(), "The T");
assertEquals(book.getFieldValue("title").getWrappedValue(), "The T");
assertEquals(book.getTitle(), "The T");
assertNull(book.getAuthor());
assertNull(book.getFieldValue("author"));
assertEquals(book.getYear(), (Integer) 2011);
assertEquals(book.getFieldValue("year").getWrappedValue(), 2011);
assertEquals(book.getIsbn(), "ISBN YEP");
assertEquals(book.getFieldValue("isbn"), new StringFieldValue("ISBN YEP"));
}
use of com.yahoo.docproc.proxy.ProxyDocument in project vespa by vespa-engine.
the class Call method configDoc.
/**
* The Document object the proc should work on. Normally the one in arguments, but could be a proxy object
* if schema mapping or @Accesses is in effect.
*
* <p>
* public for testing
*/
public DocumentPut configDoc(DocumentProcessor docProc, DocumentPut documentPut) {
if (!docProc.getFieldMap().isEmpty() || docProc.hasAnnotations()) {
Document document = documentPut.getDocument();
document = new ProxyDocument(docProc, document, docProc.getDocMap(document.getDataType().getName()));
DocumentPut newDocumentPut = new DocumentPut(document);
newDocumentPut.setCondition(documentPut.getCondition());
documentPut = newDocumentPut;
}
return documentPut;
}
Aggregations