From da92f9c81b30848fa05c1052e50782e0ddeb47c7 Mon Sep 17 00:00:00 2001 From: Aaron Klish Date: Tue, 16 Feb 2021 10:22:41 -0600 Subject: [PATCH] added one more hasmember operator IT test (#1844) Co-authored-by: Aaron Klish --- .../java/com/yahoo/elide/tests/FilterIT.java | 24 ++++++++++++++----- .../book_author_publisher_patch2.json | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/elide-integration-tests/src/test/java/com/yahoo/elide/tests/FilterIT.java b/elide-integration-tests/src/test/java/com/yahoo/elide/tests/FilterIT.java index b3b7dbac45..2b9d1804df 100644 --- a/elide-integration-tests/src/test/java/com/yahoo/elide/tests/FilterIT.java +++ b/elide-integration-tests/src/test/java/com/yahoo/elide/tests/FilterIT.java @@ -1205,11 +1205,11 @@ void testIssue508() throws JsonProcessingException { assertEquals(pageNode.get("totalRecords").asInt(), 2); result = getAsNode("book?filter=(authors.name=='Thomas Harris')&page[totals]"); - assertEquals(1, result.get("data").size()); + assertEquals(2, result.get("data").size()); pageNode = result.get("meta").get("page"); assertNotNull(pageNode); - assertEquals(pageNode.get("totalRecords").asInt(), 1); + assertEquals(pageNode.get("totalRecords").asInt(), 2); result = getAsNode("book?filter=(publisher.name=='Default publisher')&page[totals]"); assertEquals(1, result.get("data").size()); @@ -1834,6 +1834,17 @@ void testMembertoOneRelationships() { } + @Test + void testRootMemberOfToManyRelationshipConjunction() { + /* RSQL Global */ + when() + .get("/book?filter=authors.id=hasmember=1;authors.id=hasmember=2") + .then() + .body("data", hasSize(1)) + .body("data.relationships.authors[0].data.id[0]", equalTo("1")) + .body("data.relationships.authors[0].data.id[1]", equalTo("2")); + } + @Test void testRootMemberOfToManyRelationship() { /* RSQL Global */ @@ -1844,6 +1855,7 @@ void testRootMemberOfToManyRelationship() { .body("data.relationships.authors[0].data.id[0]", equalTo("1")) .body("data.relationships.authors[1].data.id[0]", equalTo("1")); + /* RSQL Typed */ when() .get("/book?filter[book]=authors.id=hasmember=1") @@ -1862,10 +1874,10 @@ void testRootMemberOfToManyRelationship() { } @Test - void testRootMemberOfToManyRelationshipConjunction() { + void testRootMemberOfAndNotMemberOfToManyRelationship() { /* RSQL Global */ when() - .get("/book?filter=authors.id=hasmember=1;authors.id=hasnomember=2") + .get("/book?filter=authors.id=hasmember=1;authors.id=hasnomember=3") .then() .body("data.relationships.authors", hasSize(2)) .body("data.relationships.authors[0].data.id[0]", equalTo("1")) @@ -1873,7 +1885,7 @@ void testRootMemberOfToManyRelationshipConjunction() { /* RSQL Typed */ when() - .get("/book?filter[book]=authors.id=hasmember=1;authors.id=hasnomember=2") + .get("/book?filter[book]=authors.id=hasmember=1;authors.id=hasnomember=3") .then() .body("data.relationships.authors", hasSize(2)) .body("data.relationships.authors[0].data.id[0]", equalTo("1")) @@ -1881,7 +1893,7 @@ void testRootMemberOfToManyRelationshipConjunction() { /* Default */ when() - .get("/book?filter[book.authors.id][hasmember]=1&filter[book.authors.id][hasnomember]=2") + .get("/book?filter[book.authors.id][hasmember]=1&filter[book.authors.id][hasnomember]=3") .then() .body("data.relationships.authors", hasSize(2)) .body("data.relationships.authors[0].data.id[0]", equalTo("1")) diff --git a/elide-integration-tests/src/test/resources/FilterIT/book_author_publisher_patch2.json b/elide-integration-tests/src/test/resources/FilterIT/book_author_publisher_patch2.json index 85fba5f5fe..cb3b8c1b7f 100644 --- a/elide-integration-tests/src/test/resources/FilterIT/book_author_publisher_patch2.json +++ b/elide-integration-tests/src/test/resources/FilterIT/book_author_publisher_patch2.json @@ -14,6 +14,10 @@ { "type": "book", "id": "12345678-1234-1234-1234-1234567890ac" + }, + { + "type": "book", + "id": "1" } ] }