use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class ScriptManagerTestCase method requireThatScriptsAreAppliedToSuperType.
@Test
public void requireThatScriptsAreAppliedToSuperType() throws ParseException {
DocumentTypeManager typeMgr = new DocumentTypeManager();
typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
DocumentType docType = typeMgr.getDocumentType("newsarticle");
assertNotNull(docType);
IlscriptsConfig.Builder config = new IlscriptsConfig.Builder();
config.ilscript(new IlscriptsConfig.Ilscript.Builder().doctype("newsarticle").content("index"));
ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(config), null);
assertNotNull(scriptMgr.getScript(typeMgr.getDocumentType("newssummary")));
assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class ScriptManagerTestCase method requireThatUnknownDocumentTypeReturnsNull.
@Test
public void requireThatUnknownDocumentTypeReturnsNull() {
DocumentTypeManager typeMgr = new DocumentTypeManager();
typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(new IlscriptsConfig.Builder()), null);
for (Iterator<DocumentType> it = typeMgr.documentTypeIterator(); it.hasNext(); ) {
assertNull(scriptMgr.getScript(it.next()));
}
assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
use of com.yahoo.document.DocumentType 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.DocumentType 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());
}
}
use of com.yahoo.document.DocumentType 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"));
}
Aggregations