use of com.yahoo.document.Document in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForBytes.
@Test
public void requireDescriptiveErrorMsgForBytes() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <bytefield></bytefield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'bytefield': Invalid byte \"\""), is(true));
}
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForDoubles.
@Test
public void requireDescriptiveErrorMsgForDoubles() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <doublefield></doublefield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'doublefield': Invalid double \"\""), is(true));
}
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class XMLNumericFieldErrorMsgTestCase method requireDescriptiveErrorMsgForLongs.
@Test
public void requireDescriptiveErrorMsgForLongs() throws Exception {
DocumentTypeManager dtm = setupTypes();
try {
VespaXMLDocumentReader documentReader = new VespaXMLDocumentReader(new ByteArrayInputStream(("<document id=\"doc:foo:bar\" type=\"doctype\">" + " <longfield></longfield>" + "</document>").getBytes(StandardCharsets.UTF_8)), dtm);
new Document(documentReader);
fail("Sorry mac");
} catch (DeserializationException e) {
assertThat(e.getMessage(), e.getMessage().contains("Field 'longfield': Invalid long \"\""), is(true));
}
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class FieldSetTestCase method testStripFields.
@Test
public void testStripFields() {
Document doc = getTestDocument();
doc.removeFieldValue("rawattr");
assertEquals("floatattr:3.56", doStripFields(doc, "[body]"));
assertEquals("stringattr:tjohei,intattr:50,byteattr:30,floatattr:3.56", doStripFields(doc, "[all]"));
assertEquals("stringattr:tjohei,intattr:50,byteattr:30", doStripFields(doc, "[header]"));
assertEquals("byteattr:30,floatattr:3.56", doStripFields(doc, "testdoc:floatattr,byteattr"));
}
use of com.yahoo.document.Document in project vespa by vespa-engine.
the class FieldSetTestCase method testCopyDocumentFields.
@Test
public void testCopyDocumentFields() {
Document doc = getTestDocument();
doc.removeFieldValue("rawattr");
assertEquals("floatattr:3.56", doCopyFields(doc, "[body]"));
assertEquals("stringattr:tjohei,intattr:50,byteattr:30,floatattr:3.56", doCopyFields(doc, "[all]"));
assertEquals("stringattr:tjohei,intattr:50,byteattr:30", doCopyFields(doc, "[header]"));
assertEquals("byteattr:30,floatattr:3.56", doCopyFields(doc, "testdoc:floatattr,byteattr"));
}
Aggregations