use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class CallbackTestCase method setUp.
public void setUp() {
service = new DocprocService("callback");
service.setCallStack(new CallStack().addNext(new TestCallbackDp()));
service.setInService(true);
// Create documents
DocumentType type = new DocumentType("test");
type.addField("status", DataType.STRING);
put1 = new DocumentPut(type, new DocumentId("doc:callback:test:1"));
put2 = new DocumentPut(type, new DocumentId("doc:callback:test:2"));
operations.add(new DocumentPut(type, new DocumentId("doc:callback:test:3")));
operations.add(new DocumentPut(type, new DocumentId("doc:callback:test:4")));
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonReaderTestCase method testDocumentRemove.
@Test
public final void testDocumentRemove() {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"remove\": \"id:unittest:smoke::whee\"" + " }}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentType docType = r.readDocumentType(new DocumentId("id:unittest:smoke::whee"));
assertEquals("smoke", docType.getName());
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonReaderTestCase method smokeTest.
@Test
public final void smokeTest() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:smoke::whee\"," + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
smokeTestDoc(put.getDocument());
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonReaderTestCase method docIdLookaheadTest.
@Test
public final void docIdLookaheadTest() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{" + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}," + "\"put\": \"id:unittest:smoke::whee\"" + "}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
smokeTestDoc(put.getDocument());
}
use of com.yahoo.document.DocumentType in project vespa by vespa-engine.
the class JsonReaderTestCase method testWeightedSet.
@Test
public final void testWeightedSet() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:testset::whee\"," + " \"fields\": { \"actualset\": {" + " \"nalle\": 2," + " \"tralle\": 7 }}}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
Document doc = put.getDocument();
FieldValue f = doc.getFieldValue(doc.getField("actualset"));
assertSame(WeightedSet.class, f.getClass());
WeightedSet<?> w = (WeightedSet<?>) f;
assertEquals(2, w.size());
assertEquals(new Integer(2), w.get(new StringFieldValue("nalle")));
assertEquals(new Integer(7), w.get(new StringFieldValue("tralle")));
}
Aggregations