File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/test/java/com/typicode/jsonplaceholder Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -39,3 +39,12 @@ Feature: Posts Endpoint
3939 """
4040 And the "userId" field in the response body has a value of 1
4141
42+ Scenario Outline : Get post with invalid ID - post #<ID>
43+ When I make a GET request to the Posts endpoint with a path parameter of <ID>
44+ Then the response has a status code of 404
45+ And the response body is an empty JSON object
46+ Examples :
47+ | ID |
48+ | 0 |
49+ | 101 |
50+ | -1 |
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public static void makeGetRequest(String endpoint) {
5757 response = RequestHelpers .sendGetRequestTo (endpoints .get (endpoint ));
5858 responses .add (response );
5959 }
60- @ When ("^I make a GET request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (\\ d+)$" )
60+ @ When ("^I make a GET request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (-? \\ d+)$" )
6161 public static void makeGetRequestWithPathParameter (String endpoint , int pathParam ) {
6262 response = RequestHelpers .sendGetRequestTo (endpoints .get (endpoint ) + "/" + pathParam );
6363 responses .add (response );
@@ -110,5 +110,10 @@ public static void verifyResponseBodyAgainstDataTable(DataTable dataTable) {
110110 expectedBody .forEach ((k ,v ) -> assertEquals (expectedBody .get (k ), actual .get (k ).toString ()));
111111 }
112112
113+ @ Then ("the response body is an empty JSON object" )
114+ public static void verifyResponseBodyIsEmptyJSONObject () {
115+ assertEquals (new JSONObject ().toString (), response .body ());
116+ }
117+
113118
114119}
You can’t perform that action at this time.
0 commit comments