Skip to content

Commit

Permalink
added one more hasmember operator IT test (#1844)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Klish <[email protected]>
  • Loading branch information
aklish and Aaron Klish authored Feb 16, 2021
1 parent 4387ca5 commit da92f9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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 */
Expand All @@ -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")
Expand All @@ -1862,26 +1874,26 @@ 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"))
.body("data.relationships.authors[1].data.id[0]", equalTo("1"));

/* 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"))
.body("data.relationships.authors[1].data.id[0]", equalTo("1"));

/* 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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{
"type": "book",
"id": "12345678-1234-1234-1234-1234567890ac"
},
{
"type": "book",
"id": "1"
}
]
}
Expand Down

0 comments on commit da92f9c

Please sign in to comment.