use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class SchemaMappingAndAccessesTest method testProxyAndSecureSecureFailing.
public void testProxyAndSecureSecureFailing() {
DocumentProcessor procInsecure = new TestDPInsecure();
Map<Pair<String, String>, String> fieldMap = new HashMap<>();
fieldMap.put(new Pair<>("album", "titleMapped"), "title");
procInsecure.setFieldMap(fieldMap);
DocumentPut put = new DocumentPut(getDoc());
Document doc = new Call(procInsecure).configDoc(procInsecure, put).getDocument();
try {
procInsecure.process(Processing.of(new DocumentPut(doc)));
fail("Insecure docproc went through");
} catch (Exception e) {
assertTrue(e.getMessage().matches(".*allowed.*"));
}
// assertEquals(doc.get("title"), "MyTitle");
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class IndexingProcessorTestCase method requireThatIndexerProcessesDocuments.
@Test
public void requireThatIndexerProcessesDocuments() {
Document input = new Document(indexer.getDocumentTypeManager().getDocumentType("music"), "doc:scheme:");
input.setFieldValue("artist", new StringFieldValue("69"));
DocumentOperation op = process(new DocumentPut(input));
assertTrue(op instanceof DocumentPut);
Document output = ((DocumentPut) op).getDocument();
assertEquals(new StringFieldValue("69"), output.getFieldValue("title"));
assertEquals("music", output.getDataType().getName());
}
use of com.yahoo.document.DocumentPut 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.DocumentPut in project vespa by vespa-engine.
the class SimpleDocumentProcessorTestCase method requireThatProcessingSingleOperationWorks.
@Test
public void requireThatProcessingSingleOperationWorks() {
DocumentType type = new DocumentType("foobar");
type.addField("title", DataType.STRING);
Processing p = getProcessing(new DocumentPut(type, "doc:this:is:a:document"));
DocprocService service = setupDocprocService(new VerySimpleDocumentProcessor());
service.getExecutor().process(p);
assertThat(p.getDocumentOperations().size(), is(1));
assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true));
assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), is("processed"));
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class SimpleDocumentProcessorTestCase method requireThatThrowingTerminatesIteration.
@Test
public void requireThatThrowingTerminatesIteration() {
DocumentType type = new DocumentType("foobar");
type.addField("title", DataType.STRING);
Processing p = getProcessing(new DocumentPut(type, "doc:this:is:a:document"), new DocumentRemove(new DocumentId("doc:this:is:a:remove")), new DocumentPut(type, "doc:this:is:a:document2"));
DocprocService service = setupDocprocService(new SimpleDocumentProcessorThrowingOnRemovesAndUpdates());
try {
service.getExecutor().process(p);
} catch (RuntimeException re) {
// ok
}
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 DocumentRemove, is(true));
assertThat(p.getDocumentOperations().get(1).getId().toString(), is("doc:this:is:a:remove"));
assertThat(p.getDocumentOperations().get(2) instanceof DocumentPut, is(true));
assertThat(((DocumentPut) p.getDocumentOperations().get(2)).getDocument().getFieldValue("title"), nullValue());
}
Aggregations