Skip to content

Commit

Permalink
Enhance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Nov 29, 2023
1 parent 9a7e18f commit 1b52cf2
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.qubitpi.ws.jersey.template.models.Book

import org.apache.http.HttpStatus

import groovy.json.JsonBuilder
import io.restassured.RestAssured
import io.restassured.response.Response
import jakarta.validation.constraints.NotNull
Expand Down Expand Up @@ -429,9 +430,11 @@ abstract class AbstractITSpec extends Specification {

def "GraphQL API can sort and paginate (effectively fetching 1 record with some min/max attribute)"() {
given: "3 entities are inserted into the database"
createBook(new Book(id: 1, title: "Pride & Prejudice"))
createBook(new Book(id: 2, title: "Effective Java"))
createBook(new Book(id: 3, title: "Critiques of Pure Reason"))
createBook(new Book(title: "Pride & Prejudice"))
createBook(new Book(title: "Effective Java"))
final String maxBookId = createBook(new Book(title: "Critiques of Pure Reason"))
.jsonPath()
.get("data.book.edges[0].node.id")
expect: "sorting by ID in descending order and paginating to get the firsts result returns Kant's work"
RestAssured
Expand Down Expand Up @@ -461,23 +464,25 @@ abstract class AbstractITSpec extends Specification {
)
.when().post().then()
.statusCode(200)
.body("", equalTo(
data: [
book: [
edges:[[
node: [
id: "3",
title:"Critiques of Pure Reason"
.body(equalTo(
new JsonBuilder(
data: [
book: [
edges:[[
node: [
id: "${maxBookId}",
title:"Critiques of Pure Reason"
]
]],
pageInfo: [
totalRecords: 3,
startCursor: "0",
endCursor: "1",
hasNextPage:true
]
]],
pageInfo: [
totalRecords: 3,
startCursor: "0",
endCursor: "1",
hasNextPage:true
]
]
] as HashMap
).toString()
))
}
Expand Down

0 comments on commit 1b52cf2

Please sign in to comment.