diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-16 11:43:45 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-16 11:43:45 +0100 |
commit | 3f07bf2d9e6eae85c50aa8734694273c983f959b (patch) | |
tree | f528075cb0e877423d9d2e26d4f6925f6ff9784c /vespaclient-container-plugin | |
parent | 416f596b150ec159717bfd2f9b2ef70e4d4cd3dd (diff) |
Test direct rendering
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r-- | vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java index cc6b8567b03..b6ad7ba5570 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java @@ -521,16 +521,66 @@ public class DocumentV1ApiTest { parameters.responseHandler().get().handleResponse(new DocumentResponse(0, doc1)); return new Result(); }); + // -- short tensors + response = driver.sendRequest("http://localhost/document/v1/space/music/docid/one?format.tensors=short"); + String shortJson = + """ + { + "pathId": "/document/v1/space/music/docid/one", + "id": "id:space:music::one", + "fields": { + "artist": "Tom Waits", + "embedding": { "type": "tensor(x[3])","values": [1.0, 2.0, 3.0]} + } + } + """; + assertEquals(200, response.getStatus()); + assertSameJson(shortJson, response.readAll()); + // -- long tensors response = driver.sendRequest("http://localhost/document/v1/space/music/docid/one?format.tensors=long"); - assertSameJson("{" + - " \"pathId\": \"/document/v1/space/music/docid/one\"," + - " \"id\": \"id:space:music::one\"," + - " \"fields\": {" + - " \"artist\": \"Tom Waits\"," + - " \"embedding\": { \"type\": \"tensor(x[3])\",\"cells\": [{\"address\":{\"x\":\"0\"},\"value\":1.0},{\"address\":{\"x\":\"1\"},\"value\": 2.0},{\"address\":{\"x\":\"2\"},\"value\": 3.0}]}" + - " }" + - "}", response.readAll()); + String longJson = + """ + { + "pathId": "/document/v1/space/music/docid/one", + "id": "id:space:music::one", + "fields": { + "artist": "Tom Waits", + "embedding": { "type": "tensor(x[3])","cells": [{"address":{"x":"0"},"value":1.0},{"address":{"x":"1"},"value": 2.0},{"address":{"x":"2"},"value": 3.0}]} + } + } + """; + assertEquals(200, response.getStatus()); + assertSameJson(longJson, response.readAll()); + // -- short direct tensors + response = driver.sendRequest("http://localhost/document/v1/space/music/docid/one?format.tensors=short-value"); + String shortDirectJson = + """ + { + "pathId": "/document/v1/space/music/docid/one", + "id": "id:space:music::one", + "fields": { + "artist": "Tom Waits", + "embedding": [1.0, 2.0, 3.0]} + } + } + """; + assertEquals(200, response.getStatus()); + assertSameJson(shortDirectJson, response.readAll()); + // -- long direct tensors + response = driver.sendRequest("http://localhost/document/v1/space/music/docid/one?format.tensors=long-value"); + String longDirectJson = + """ + { + "pathId": "/document/v1/space/music/docid/one", + "id": "id:space:music::one", + "fields": { + "artist": "Tom Waits", + "embedding": [{"address":{"x":"0"},"value":1.0},{"address":{"x":"1"},"value": 2.0},{"address":{"x":"2"},"value": 3.0}] + } + } + """; assertEquals(200, response.getStatus()); + assertSameJson(longDirectJson, response.readAll()); // GET with not encoded / in user specified part of document id is perfectly OK ... щ(ಥДಥщ) access.session.expect((id, parameters) -> { |