aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-13 13:55:54 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-13 13:55:54 +0100
commita289581cbf94ff6997356110b54bd6993e956b9e (patch)
treeae2d2ee5e4fd7cb64642c8f7a99a1b9d2ab98111 /document/src/test/java/com/yahoo
parentfeb27aa51f1274e2b247b8f764f3293c7e5f1ad6 (diff)
Handle type rendering
- Always output type for consistency. - Ignore type in input.
Diffstat (limited to 'document/src/test/java/com/yahoo')
-rw-r--r--document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java1
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java8
2 files changed, 6 insertions, 3 deletions
diff --git a/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java b/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java
index 7bdb526bb1c..08a5c9a124c 100644
--- a/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java
+++ b/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java
@@ -285,6 +285,7 @@ public class DocumentUpdateJsonSerializerTest {
" 'fields': {",
" 'sparse_tensor': {",
" 'assign': {",
+ " 'type': 'tensor(x{},y{})',",
" 'cells': [",
" { 'address': { 'x': 'a', 'y': 'b' }, 'value': 2.0 },",
" { 'address': { 'x': 'c', 'y': 'b' }, 'value': 3.0 }",
diff --git a/document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java
index e7368a691ab..edf410b312e 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java
@@ -396,19 +396,21 @@ public class JsonWriterTestCase {
@Test
public void testWritingOfEmptyTensor() throws IOException {
- assertTensorRoundTripEquality("{}","{ \"cells\": [] }");
+ assertTensorRoundTripEquality("{}","{ \"type\":\"tensor(x{},y{})\", \"cells\": [] }");
}
@Test
public void testWritingOfTensorWithCellsOnly() throws IOException {
assertTensorRoundTripEquality("{ "
- + " \"cells\": [ "
+ + " \"type\": \"tensor(x{},y{})\","
+ + " \"cells\": [ "
+ " { \"address\": { \"x\": \"a\", \"y\": \"b\" }, "
+ " \"value\": 2.0 }, "
+ " { \"address\": { \"x\": \"c\", \"y\": \"b\" }, "
+ " \"value\": 3.0 } "
+ " ]"
+ "}", "{ "
+ + " \"type\": \"tensor(x{},y{})\","
+ " \"cells\": [ "
+ " { \"address\": { \"x\": \"a\", \"y\": \"b\" }, "
+ " \"value\": 2.0 }, "
@@ -449,7 +451,7 @@ public class JsonWriterTestCase {
Tensor tensor = Tensor.from("tensor(x[3]):[1,2,3]");
doc.setFieldValue(tensorField, new TensorFieldValue(tensor));
- assertEqualJson(asDocument(docId, "{ \"tensorfield\": {\"cells\":[{\"address\":{\"x\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"1\"},\"value\":2.0},{\"address\":{\"x\":\"2\"},\"value\":3.0}]} }"),
+ assertEqualJson(asDocument(docId, "{ \"tensorfield\": {\"type\":\"tensor(x[3])\", \"cells\":[{\"address\":{\"x\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"1\"},\"value\":2.0},{\"address\":{\"x\":\"2\"},\"value\":3.0}]} }"),
writeDocument(doc, false));
assertEqualJson(asDocument(docId, "{ \"tensorfield\": {\"type\":\"tensor(x[3])\", \"values\":[1.0, 2.0, 3.0] } }"),
writeDocument(doc, true));