@Test
    @Timeout(300)
    void testTensorRendering() throws ExecutionException, InterruptedException, IOException {
        String shortJson = """
                {
                  "root": {
                    "id":"toplevel",
                    "relevance":1.0,
                    "fields":{
                      "totalCount":1
                    },
                    "children":[{
                      "id":"tensors",
                      "relevance":1.0,
                      "fields":{
                        "tensor_standard":{"type":"tensor(x{},y{})","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}]},
                        "tensor_indexed":{"type":"tensor<bfloat16>(x[2],y[3])","values":[[1.0,2.0,3.0],[4.0,5.0,6.0]]},
                        "tensor_single_mapped":{"type":"tensor(x{})","cells":{"a":1.0,"b":2.0}},
                        "tensor_mixed":{"type":"tensor<bfloat16>(x{},y[2])","blocks":{"a":[1.0,2.0],"b":[3.0,4.0]}},
                        "summaryfeatures":{
                          "tensor_standard":{"type":"tensor(x{},y{})","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}]},
                          "tensor_indexed":{"type":"tensor<bfloat16>(x[2],y[3])","values":[[1.0,2.0,3.0],[4.0,5.0,6.0]]},
                          "tensor_single_mapped":{"type":"tensor(x{})","cells":{"a":1.0,"b":2.0}},
                          "tensor_mixed":{"type":"tensor<bfloat16>(x{},y[2])","blocks":{"a":[1.0,2.0],"b":[3.0,4.0]}}
                        }
                      }
                    }]
                  }
                }""";

        String longJson = """
                {
                  "root": {
                    "id":"toplevel",
                    "relevance":1.0,
                    "fields":{
                      "totalCount":1
                    },
                    "children":[{
                      "id":"tensors",
                      "relevance":1.0,
                      "fields":{
                        "tensor_standard":{"type":"tensor(x{},y{})","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}]},
                        "tensor_indexed":{"type":"tensor<bfloat16>(x[2],y[3])","cells":[{"address":{"x":"0","y":"0"},"value":1.0},{"address":{"x":"0","y":"1"},"value":2.0},{"address":{"x":"0","y":"2"},"value":3.0},{"address":{"x":"1","y":"0"},"value":4.0},{"address":{"x":"1","y":"1"},"value":5.0},{"address":{"x":"1","y":"2"},"value":6.0}]},
                        "tensor_single_mapped":{"type":"tensor(x{})","cells":[{"address":{"x":"a"},"value":1.0},{"address":{"x":"b"},"value":2.0}]},
                        "tensor_mixed":{"type":"tensor<bfloat16>(x{},y[2])","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"a","y":"1"},"value":2.0},{"address":{"x":"b","y":"0"},"value":3.0},{"address":{"x":"b","y":"1"},"value":4.0}]},
                        "summaryfeatures":{
                          "tensor_standard":{"type":"tensor(x{},y{})","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}]},
                          "tensor_indexed":{"type":"tensor<bfloat16>(x[2],y[3])","cells":[{"address":{"x":"0","y":"0"},"value":1.0},{"address":{"x":"0","y":"1"},"value":2.0},{"address":{"x":"0","y":"2"},"value":3.0},{"address":{"x":"1","y":"0"},"value":4.0},{"address":{"x":"1","y":"1"},"value":5.0},{"address":{"x":"1","y":"2"},"value":6.0}]},
                          "tensor_single_mapped":{"type":"tensor(x{})","cells":[{"address":{"x":"a"},"value":1.0},{"address":{"x":"b"},"value":2.0}]},
                          "tensor_mixed":{"type":"tensor<bfloat16>(x{},y[2])","cells":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"a","y":"1"},"value":2.0},{"address":{"x":"b","y":"0"},"value":3.0},{"address":{"x":"b","y":"1"},"value":4.0}]}
                        }
                      }
                    }]
                  }
                }""";

        String shortDirectJson = """
                {
                  "root": {
                    "id":"toplevel",
                    "relevance":1.0,
                    "fields":{
                      "totalCount":1
                    },
                    "children":[{
                      "id":"tensors",
                      "relevance":1.0,
                      "fields":{
                        "tensor_standard":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}],
                        "tensor_indexed":[[1.0,2.0,3.0],[4.0,5.0,6.0]],
                        "tensor_single_mapped":{"a":1.0,"b":2.0},
                        "tensor_mixed":{"a":[1.0,2.0],"b":[3.0,4.0]},
                        "summaryfeatures":{
                          "tensor_standard":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}],
                          "tensor_indexed":[[1.0,2.0,3.0],[4.0,5.0,6.0]],
                          "tensor_single_mapped":{"a":1.0,"b":2.0},
                          "tensor_mixed":{"a":[1.0,2.0],"b":[3.0,4.0]}
                        }
                      }
                    }]
                  }
                }""";

        String longDirectJson = """
                {
                  "root": {
                    "id":"toplevel",
                    "relevance":1.0,
                    "fields":{
                      "totalCount":1
                    },
                    "children":[{
                      "id":"tensors",
                      "relevance":1.0,
                      "fields":{
                        "tensor_standard":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}],
                        "tensor_indexed":[{"address":{"x":"0","y":"0"},"value":1.0},{"address":{"x":"0","y":"1"},"value":2.0},{"address":{"x":"0","y":"2"},"value":3.0},{"address":{"x":"1","y":"0"},"value":4.0},{"address":{"x":"1","y":"1"},"value":5.0},{"address":{"x":"1","y":"2"},"value":6.0}],
                        "tensor_single_mapped":[{"address":{"x":"a"},"value":1.0},{"address":{"x":"b"},"value":2.0}],
                        "tensor_mixed":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"a","y":"1"},"value":2.0},{"address":{"x":"b","y":"0"},"value":3.0},{"address":{"x":"b","y":"1"},"value":4.0}],
                        "summaryfeatures":{
                          "tensor_standard":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"b","y":"1"},"value":2.0}],
                          "tensor_indexed":[{"address":{"x":"0","y":"0"},"value":1.0},{"address":{"x":"0","y":"1"},"value":2.0},{"address":{"x":"0","y":"2"},"value":3.0},{"address":{"x":"1","y":"0"},"value":4.0},{"address":{"x":"1","y":"1"},"value":5.0},{"address":{"x":"1","y":"2"},"value":6.0}],
                          "tensor_single_mapped":[{"address":{"x":"a"},"value":1.0},{"address":{"x":"b"},"value":2.0}],
                          "tensor_mixed":[{"address":{"x":"a","y":"0"},"value":1.0},{"address":{"x":"a","y":"1"},"value":2.0},{"address":{"x":"b","y":"0"},"value":3.0},{"address":{"x":"b","y":"1"},"value":4.0}]
                        }
                      }
                    }]
                  }
                }""";

        assertTensorRendering(shortJson, "short");
        assertTensorRendering(longJson, "long");
        assertTensorRendering(shortDirectJson, "short-value");
        assertTensorRendering(longDirectJson, "long-value");

        String hexJson = """
                {
                  "root": {
                    "id": "toplevel",
                    "relevance": 1.0,
                    "fields": {
                      "totalCount": 1
                    },
                    "children": [
                      {
                        "id": "tensors",
                        "relevance": 1.0,
                        "fields": {
                          "tensor_standard": { "type": "tensor(x{},y{})", "cells": [ { "address": { "x": "a", "y": "0" }, "value": 1.0 }, { "address": { "x": "b", "y": "1" }, "value": 2.0 } ] },
                          "tensor_indexed": { "type": "tensor<bfloat16>(x[2],y[3])", "values": "3F8040004040408040A040C0" },
                          "tensor_single_mapped": { "type": "tensor(x{})", "cells": { "a": 1.0, "b": 2.0 } },
                          "tensor_mixed": { "type": "tensor<bfloat16>(x{},y[2])", "blocks": { "a": "3F804000", "b": "40404080" } },
                          "summaryfeatures": {
                            "tensor_standard": { "type": "tensor(x{},y{})", "cells": [ { "address": { "x": "a", "y": "0" }, "value": 1.0 }, { "address": { "x": "b", "y": "1" }, "value": 2.0 } ] },
                            "tensor_indexed": { "type": "tensor<bfloat16>(x[2],y[3])", "values": "3F8040004040408040A040C0" },
                            "tensor_single_mapped": { "type": "tensor(x{})", "cells": { "a": 1.0, "b": 2.0 } },
                            "tensor_mixed": { "type": "tensor<bfloat16>(x{},y[2])", "blocks": { "a": "3F804000", "b": "40404080" } }
                          }
                        }
                      }
                    ]
                  }
                }""";

        String hexDirectJson = """
                {
                  "root": {
                    "id": "toplevel",
                    "relevance": 1.0,
                    "fields": {
                      "totalCount": 1
                    },
                    "children": [
                      {
                        "id": "tensors",
                        "relevance": 1.0,
                        "fields": {
                          "tensor_standard": [
                            { "address": { "x": "a", "y": "0" }, "value": 1.0 },
                            { "address": { "x": "b", "y": "1" }, "value": 2.0 }
                          ],
                          "tensor_indexed": "3F8040004040408040A040C0",
                          "tensor_single_mapped": { "a": 1.0, "b": 2.0 },
                          "tensor_mixed": { "a": "3F804000", "b": "40404080" },
                          "summaryfeatures": {
                            "tensor_standard": [
                              { "address": { "x": "a", "y": "0" }, "value": 1.0 },
                              { "address": { "x": "b", "y": "1" }, "value": 2.0 }
                            ],
                            "tensor_indexed": "3F8040004040408040A040C0",
                            "tensor_single_mapped": { "a": 1.0, "b": 2.0 },
                            "tensor_mixed": { "a": "3F804000", "b": "40404080" }
                          }
                        }
                      }
                    ]
                  }
                }""";

        assertTensorRendering(hexJson, "hex");
        assertTensorRendering(hexDirectJson, "hex-value");

        try {
            render(new Result(new Query("/?presentation.format.tensors=unknown")));
            fail("Expected exception");
        }
        catch (IllegalArgumentException e) {
            assertEquals("Could not set 'presentation.format.tensors' to 'unknown': Value must be 'long', 'short', 'long-value', or 'short-value', not 'unknown'",
                         Exceptions.toMessageString(e));
        }
    }
Functional testing of {@link JsonRenderer}.

@author Steinar Knutsen
@author bratseth
container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java