use of com.yahoo.document.Field in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method requireThatMapKeyDeserializeExceptionIncludesFieldName.
@Test
public void requireThatMapKeyDeserializeExceptionIncludesFieldName() throws Exception {
Field field = new Field("my_field", DataType.getMap(DataType.BYTE, DataType.STRING));
assertThrows(field, "<assign field='my_field'><item><key>-129</key><value>foo</value></item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 87)");
assertThrows(field, "<assign fieldpath='my_field'><item><key>-129</key><value>foo</value></item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 91)");
assertThrows(field, "<add field='my_field'><item><key>-129</key><value>foo</value></item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 84)");
assertThrows(field, "<add fieldpath='my_field'><item><key>-129</key><value>foo</value></item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 88)");
assertThrows(field, "<remove field='my_field'><item><key>-129</key><value>foo</value></item></remove>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 87)");
try {
readUpdate(field, "<remove fieldpath='my_field{-129}' />");
fail();
} catch (NumberFormatException e) {
}
}
use of com.yahoo.document.Field in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method requireThatMapValueDeserializeExceptionIncludesFieldName.
@Test
public void requireThatMapValueDeserializeExceptionIncludesFieldName() throws Exception {
Field field = new Field("my_field", DataType.getMap(DataType.STRING, DataType.BYTE));
assertThrows(field, "<assign field='my_field'><item><key>foo</key><value>-129</value></item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 105)");
assertThrows(field, "<assign fieldpath='my_field'><item><key>foo</key><value>-129</value></item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 109)");
assertThrows(field, "<add field='my_field'><item><key>foo</key><value>-129</value></item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 102)");
assertThrows(field, "<add fieldpath='my_field'><item><key>foo</key><value>-129</value></item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 106)");
assertThrows(field, "<remove field='my_field'><item><key>foo</key><value>-129</value></item></remove>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 105)");
}
use of com.yahoo.document.Field in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method requireThatFieldPathWhereClauseIsValidated.
@Test
@Ignore
public void requireThatFieldPathWhereClauseIsValidated() throws Exception {
// tracked in ticket 6675091
// problem caused by VespaXMLUpdateReader#read(FieldPathUpdate) not validating where clause
assertThrows(new Field("my_field", DataType.getArray(DataType.BYTE)), "<remove fieldpath='my_field[$x]' where='my_field[$x] == -129' />", "Field 'my_field': Invalid byte \"-129\". (at line 1, column X)");
assertThrows(new Field("my_field", DataType.getMap(DataType.STRING, DataType.BYTE)), "<remove fieldpath='my_field{$x}' where='my_field{$x} == -129' />", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 109)");
}
use of com.yahoo.document.Field in project vespa by vespa-engine.
the class VespaXmlUpdateReaderTestCase method requireThatArrayItemDeserializeExceptionIncludesFieldName.
@Test
public void requireThatArrayItemDeserializeExceptionIncludesFieldName() throws Exception {
Field field = new Field("my_field", DataType.getArray(DataType.BYTE));
assertThrows(field, "<assign field='my_field'><item>-129</item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 83)");
assertThrows(field, "<assign fieldpath='my_field'><item>-129</item></assign>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 87)");
assertThrows(field, "<add field='my_field'><item>-129</item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 80)");
assertThrows(field, "<add fieldpath='my_field'><item>-129</item></add>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 84)");
assertThrows(field, "<remove field='my_field'><item>-129</item></remove>", "Field 'my_field': Invalid byte \"-129\". (at line 1, column 83)");
}
use of com.yahoo.document.Field in project vespa by vespa-engine.
the class JsonWriterTestCase method testWritingOfTensorFieldValueWithoutTensor.
@Test
public void testWritingOfTensorFieldValueWithoutTensor() throws IOException {
DocumentType documentTypeWithTensor = types.getDocumentType("testtensor");
String docId = "id:unittest:testtensor::0";
Document doc = new Document(documentTypeWithTensor, docId);
Field tensorField = documentTypeWithTensor.getField("tensorfield");
doc.setFieldValue(tensorField, new TensorFieldValue(((TensorDataType) tensorField.getDataType()).getTensorType()));
assertEqualJson(asDocument(docId, "{ \"tensorfield\": {} }"), JsonWriter.toByteArray(doc));
}
Aggregations