diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-13 13:55:54 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-13 13:55:54 +0100 |
commit | a289581cbf94ff6997356110b54bd6993e956b9e (patch) | |
tree | ae2d2ee5e4fd7cb64642c8f7a99a1b9d2ab98111 /document/src/test | |
parent | feb27aa51f1274e2b247b8f764f3293c7e5f1ad6 (diff) |
Handle type rendering
- Always output type for consistency.
- Ignore type in input.
Diffstat (limited to 'document/src/test')
-rw-r--r-- | document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java | 1 | ||||
-rw-r--r-- | document/src/test/java/com/yahoo/document/json/JsonWriterTestCase.java | 8 |
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)); |