use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class DocumentTestCase method validateCppDoc.
public void validateCppDoc(Document doc) throws IOException {
validateCppDocNotMap(doc);
MapFieldValue map = (MapFieldValue) doc.getFieldValue("mapfield");
assertEquals(map.get(new StringFieldValue("foo1")), new StringFieldValue("bar1"));
assertEquals(map.get(new StringFieldValue("foo2")), new StringFieldValue("bar2"));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class Bug4475379TestCase method testClone.
@Test
public void testClone() {
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "doc:this:is:a:test");
doc.setFieldValue("body", new StringFieldValue(""));
annotate(manager, doc);
Document anotherDoc = doc.clone();
assertThat(doc, equalTo(anotherDoc));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class Bug6425939TestCase method canDeserializeAnnotationsOnZeroLengthStrings.
@Test
public void canDeserializeAnnotationsOnZeroLengthStrings() {
StringFieldValue emptyString = new StringFieldValue("");
emptyString.setSpanTree(createSpanTree());
GrowableByteBuffer buffer = new GrowableByteBuffer(1024);
DocumentSerializer serializer = DocumentSerializerFactory.create42(buffer);
Field strField = new Field("flarn", DataType.STRING);
serializer.write(strField, emptyString);
buffer.flip();
// Should not throw exception if bug 6425939 is fixed:
DocumentDeserializer deserializer = DocumentDeserializerFactory.create42(man, buffer);
StringFieldValue deserializedString = new StringFieldValue();
deserializer.read(strField, deserializedString);
assertEquals("", deserializedString.getString());
SpanTree readTree = deserializedString.getSpanTree("SpanTree1");
assertNotNull(readTree);
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SpanListAdvTestCase method getAnnotationsForNode.
public void getAnnotationsForNode(SpanNode node) {
Iterator<Annotation> iter = tree.iterator(node);
boolean annotationPresent = false;
while (iter.hasNext()) {
annotationPresent = true;
Annotation xx = iter.next();
AnnotationType t = xx.getType();
StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
if (debug)
System.out.println("Annotation: " + xx);
if (fValue == null) {
if (debug)
System.out.println("Field Value is null");
return;
} else {
if (debug)
System.out.println("Field Value: " + fValue.getString());
}
}
if (!annotationPresent) {
if (debug)
System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
}
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class SpanNodeAdvTestCase method getAnnotationsForNode.
public void getAnnotationsForNode(SpanNode node) {
Iterator<Annotation> iter = tree.iterator(node);
boolean annotationPresent = false;
while (iter.hasNext()) {
annotationPresent = true;
Annotation xx = iter.next();
AnnotationType t = xx.getType();
StringFieldValue fValue = (StringFieldValue) xx.getFieldValue();
if (debug)
System.out.println("Annotation: " + xx);
if (fValue == null) {
if (debug)
System.out.println("Field Value is null");
return;
} else {
if (debug)
System.out.println("Field Value: " + fValue.getString());
}
}
if (!annotationPresent) {
if (debug)
System.out.println("****No annotations found for the span node: [" + node.getFrom() + ", " + node.getTo() + "] ");
}
}
Aggregations