diff options
Diffstat (limited to 'vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource')
2 files changed, 22 insertions, 3 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 97f45c4062a..9134805da98 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 @@ -18,9 +18,11 @@ public class MockedOperationHandler implements OperationHandler { int deleteCount = 0; @Override - public VisitResult visit(RestUri restUri, String documentSelection, Optional<String> cluster, Optional<String> continuation) throws RestApiException { - return new VisitResult(Optional.of("token"), "List of json docs, cont token " + continuation.map(a->a).orElse("not set") + ", doc selection: '" - + documentSelection + "'"); + public VisitResult visit(RestUri restUri, String documentSelection, VisitOptions options) throws RestApiException { + return new VisitResult(Optional.of("token"), "List of json docs, cont token " + + options.continuation.map(a->a).orElse("not set") + ", doc selection: '" + + documentSelection + "'" + + options.wantedDocumentCount.map(n -> String.format(", min docs returned: %d", n)).orElse("")); } @Override 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 10ae80a5d03..91390e3a0d8 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 @@ -270,6 +270,7 @@ public class RestApiTest { assertThat(rest, containsString(visit_response_part3)); } + // TODO why is this a limitation? String visit_test_bad_uri = "/document/v1/namespace/document-type/group/abc?continuation=abc&selection=foo"; String visit_test_bad_response = "Visiting does not support setting value for group/value in combination with expression"; @@ -294,6 +295,22 @@ public class RestApiTest { assertThat(rest, containsString(visit_test_response_selection_rewrite)); } + @Test + public void wanted_document_count_returned_parameter_is_propagated() throws IOException { + Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?wantedDocumentCount=321", getFirstListenPort())); + HttpGet get = new HttpGet(request.getUri()); + String rest = doRest(get); + assertThat(rest, containsString("min docs returned: 321")); + } + + @Test + public void wanted_document_count_parameter_returns_error_response() throws IOException { + Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?wantedDocumentCount=aardvark", getFirstListenPort())); + HttpGet get = new HttpGet(request.getUri()); + String rest = doRest(get); + assertThat(rest, containsString("Invalid 'wantedDocumentCount' value. Expected integer")); + } + private String doRest(HttpRequestBase request) throws IOException { HttpClient client = HttpClientBuilder.create().build(); HttpResponse response = client.execute(request); |