summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@oath.com>2018-04-10 14:40:43 +0200
committerTor Brede Vekterli <vekterli@oath.com>2018-04-10 14:40:43 +0200
commitbf8586f5c5d4456b159573c22066bf395f043607 (patch)
tree35a7c43ba4c17faa1319b6d6803f54fe694e3ad3 /vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java
parent22ed89fdcab1a4f01eb3c6641784d151b84b44d1 (diff)
Allow both group/numeric ID and selection to be specified at the same time
Resulting selection expression is a conjunction of the group/number ID sub-expression and the provided selection sub-expression.
Diffstat (limited to 'vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java')
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiTest.java36
1 files changed, 22 insertions, 14 deletions
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 be8915496ac..ed7935b698b 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
@@ -280,23 +280,9 @@ 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";
-
-
- @Test
- public void testBadVisit() throws Exception {
- Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_bad_uri);
- HttpGet get = new HttpGet(request.getUri());
- String rest = doRest(get);
- assertThat(rest, containsString(visit_test_bad_response));
- }
-
String visit_test_uri_selection_rewrite = "/document/v1/namespace/document-type/group/abc?continuation=abc";
String visit_test_response_selection_rewrite = "doc selection: 'id.group=='abc''";
-
@Test
public void testUseExpressionOnVisit() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_uri_selection_rewrite);
@@ -354,6 +340,28 @@ public class RestApiTest {
}
@Test
+ public void can_specify_numeric_id_without_explicit_selection() {
+ assertResultingDocumentSelection("number/1234", "id.user==1234");
+ }
+
+ @Test
+ public void can_specify_group_id_without_explicit_selection() {
+ assertResultingDocumentSelection("group/foo", "id.group=='foo'");
+ }
+
+ @Test
+ public void can_specify_both_numeric_id_and_explicit_selection() {
+ assertResultingDocumentSelection(String.format("number/1234?selection=%s", encoded("1 != 2")),
+ "id.user==1234 and (1 != 2)");
+ }
+
+ @Test
+ public void can_specify_both_group_id_and_explicit_selection() {
+ assertResultingDocumentSelection(String.format("group/bar?selection=%s", encoded("3 != 4")),
+ "id.group=='bar' and (3 != 4)");
+ }
+
+ @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());