diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-02-08 17:43:02 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@oath.com> | 2018-02-08 17:43:02 +0100 |
commit | 6961959b71f84f2cece6538d8c5c6bed9871dc8c (patch) | |
tree | 7ae4247d398e731d4bdd465ed1fb9732ec9aa597 /vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource | |
parent | de59b17780e0a205dc91c36bb8338f0482229be4 (diff) |
Also support fieldSet for Document V1 get operations
Now has parity with visit operations and the legacy API.
Diffstat (limited to 'vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource')
2 files changed, 20 insertions, 6 deletions
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java index 3b16d9a378c..297576f1bef 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java @@ -55,9 +55,16 @@ public class MockedOperationHandler implements OperationHandler { } @Override - public Optional<String> get(RestUri restUri) throws RestApiException { + public Optional<String> get(RestUri restUri, Optional<String> fieldSet) throws RestApiException { log.append("GET: " + restUri.generateFullId()); - return Optional.empty(); + // This is _not_ an elegant way to return data back to the test. + // An alternative is removing this entire class in favor of explicit mock expectations. + return fieldSet.map(fs -> String.format("{\"fields\": {\"fieldset\": \"%s\"}}", fs)); + } + + @Override + public Optional<String> get(RestUri restUri) throws RestApiException { + return get(restUri, Optional.empty()); } } diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java index faee5947794..eb06af41348 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java @@ -254,12 +254,19 @@ public class RestApiTest { assertThat(rest, containsString(get_enc_response_part2)); } + @Test + public void get_fieldset_parameter_is_propagated() throws IOException { + Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/bar?fieldSet=foo,baz", getFirstListenPort())); + HttpGet get = new HttpGet(request.getUri()); + String rest = doRest(get); + assertThat(rest, containsString("\"fieldset\":\"foo,baz\"")); + } + String visit_test_uri = "/document/v1/namespace/document-type/docid/?continuation=abc"; String visit_response_part1 = "\"documents\":[List of json docs, cont token abc, doc selection: '']"; String visit_response_part2 = "\"continuation\":\"token\""; String visit_response_part3 = "\"pathId\":\"/document/v1/namespace/document-type/docid/\""; - @Test public void testbasicVisit() throws Exception { Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_uri); @@ -320,7 +327,7 @@ public class RestApiTest { } @Test - public void fieldset_parameter_is_propagated() throws IOException { + public void visit_fieldset_parameter_is_propagated() throws IOException { Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?fieldSet=foo,baz", getFirstListenPort())); HttpGet get = new HttpGet(request.getUri()); String rest = doRest(get); @@ -328,7 +335,7 @@ public class RestApiTest { } @Test - public void concurrency_parameter_is_propagated() throws IOException { + public void visit_concurrency_parameter_is_propagated() throws IOException { Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?concurrency=42", getFirstListenPort())); HttpGet get = new HttpGet(request.getUri()); String rest = doRest(get); @@ -336,7 +343,7 @@ public class RestApiTest { } @Test - public void invalid_concurrency_parameter_returns_error_response() throws IOException { + public void invalid_visit_concurrency_parameter_returns_error_response() throws IOException { Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?concurrency=badgers", getFirstListenPort())); HttpGet get = new HttpGet(request.getUri()); String rest = doRest(get); |