Skip to content

Commit 87cc458

Browse files
committed
Test equivalence between endpoints
1 parent bd3958e commit 87cc458

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/test/java/com/typicode/jsonplaceholder/features/Posts.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,8 @@ Feature: Posts Endpoint
217217
And the response body follows the "MultiplePosts" JSON schema
218218
And the results array contains 100 elements
219219
And the response body matches the "AllPosts" expected response
220+
221+
Scenario: Query parameter and nested path parameter equivalence across endpoints
222+
When I make a GET request to the Posts endpoint with a "userId" query parameter of 1
223+
And I make a GET request to the Users endpoint with nested path parameters of 1/posts
224+
Then the two response bodies are identical

src/test/java/com/typicode/jsonplaceholder/steps/CommonSteps.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ public static void makeGetRequestWithQueryParameter(String endpoint, String key,
111111
responses.add(response);
112112
}
113113

114+
@When("^I make a GET request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with nested path parameters of (-?\\d+\\/\\w+)$")
115+
public static void makeRequestWithNestedParameters(String endpoint, String nestedParam) {
116+
response = RequestHelpers.sendGetRequestTo(endpoints.get(endpoint) + "/" + nestedParam);
117+
responses.add(response);
118+
}
114119
@Then("the response has a status code of {int}")
115120
public static void verifyResponseStatusCode(int code) {
116121
assertEquals(code, response.statusCode());

0 commit comments

Comments
 (0)