aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-16 11:43:45 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-16 11:43:45 +0100
commit3f07bf2d9e6eae85c50aa8734694273c983f959b (patch)
treef528075cb0e877423d9d2e26d4f6925f6ff9784c /document/src/test/java/com/yahoo
parent416f596b150ec159717bfd2f9b2ef70e4d4cd3dd (diff)
Test direct rendering
Diffstat (limited to 'document/src/test/java/com/yahoo')
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java50
1 files changed, 36 insertions, 14 deletions
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index c19094ff231..f48c2330f82 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -1427,14 +1427,16 @@ public class JsonReaderTestCase {
@Test
public void testParsingOfSparseTensorWithCells() {
Tensor tensor = assertSparseTensorField("{{x:a,y:b}:2.0,{x:c,y:b}:3.0}}",
- createPutWithSparseTensor(inputJson("{",
- " 'cells': [",
- " { 'address': { 'x': 'a', 'y': 'b' },",
- " 'value': 2.0 },",
- " { 'address': { 'x': 'c', 'y': 'b' },",
- " 'value': 3.0 }",
- " ]",
- "}")));
+ createPutWithSparseTensor(
+ """
+ {
+ "type": "tensor(x{},y{})",
+ "cells": [
+ { "address": { "x": "a", "y": "b" }, "value": 2.0 },
+ { "address": { "x": "c", "y": "b" }, "value": 3.0 }
+ ]
+ }
+ """));
assertTrue(tensor instanceof MappedTensor); // any functional instance is fine
}
@@ -1542,13 +1544,33 @@ public class JsonReaderTestCase {
builder.cell().label("x", 1).label("y", 2).value(7.0);
Tensor expected = builder.build();
- String mixedJson = "{\"blocks\":[" +
- "{\"address\":{\"x\":\"0\"},\"values\":[2.0,3.0,4.0]}," +
- "{\"address\":{\"x\":\"1\"},\"values\":[5.0,6.0,7.0]}" +
- "]}";
+ String mixedJson =
+ """
+ {
+ "blocks":[
+ {"address":{"x":"0"},"values":[2.0,3.0,4.0]},
+ {"address":{"x":"1"},"values":[5.0,6.0,7.0]}
+ ]
+ }
+ """;
Tensor tensor = assertTensorField(expected,
createPutWithTensor(inputJson(mixedJson), "mixed_tensor"), "mixed_tensor");
assertTrue(tensor instanceof MixedTensor); // this matters for performance
+
+ String mixedJsonDirect =
+ """
+ [
+ {"address":{"x":"0","y":"0"},"value":2.0},
+ {"address":{"x":"0","y":"1"},"value":3.0},
+ {"address":{"x":"0","y":"2"},"value":4.0},
+ {"address":{"x":"1","y":"0"},"value":5.0},
+ {"address":{"x":"1","y":"1"},"value":6.0},
+ {"address":{"x":"1","y":"2"},"value":7.0}
+ ]
+ """;
+ Tensor tensorDirect = assertTensorField(expected,
+ createPutWithTensor(inputJson(mixedJsonDirect), "mixed_tensor"), "mixed_tensor");
+ assertTrue(tensorDirect instanceof MixedTensor); // this matters for performance
}
@Test
@@ -1602,8 +1624,8 @@ public class JsonReaderTestCase {
@Test
public void testAssignUpdateOfNullTensor() {
ClearValueUpdate clearUpdate = (ClearValueUpdate) getTensorField(createAssignUpdateWithSparseTensor(null)).getValueUpdate(0);
- assertTrue(clearUpdate != null);
- assertTrue(clearUpdate.getValue() == null);
+ assertNotNull(clearUpdate);
+ assertNull(clearUpdate.getValue());
}
@Test