@@ -50,41 +50,38 @@ public static void setup() {
5050 responses = new ArrayList <>();
5151 }
5252
53- @ When ("^I make a GET request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
54- public static void makeGetRequest (String endpoint ) {
55- response = RequestHelpers .sendGetRequestTo (endpoints .get (endpoint ));
53+ @ When ("^I make a (GET|DELETE) request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
54+ public static void makeRequest (String requestType , String endpoint ) {
55+ response = requestType .equals ("GET" ) ?
56+ RequestHelpers .sendGetRequestTo (endpoints .get (endpoint )) :
57+ RequestHelpers .sendDeleteRequestTo ((endpoints .get (endpoint )));
5658 responses .add (response );
5759 }
5860
59- @ When ("^I make a GET request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (-?\\ d+)$" )
60- public static void makeGetRequestWithPathParameter (String endpoint , int pathParam ) {
61- response = RequestHelpers .sendGetRequestTo (endpoints .get (endpoint ) + "/" + pathParam );
61+ @ When ("^I make a (GET|DELETE) request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (-?\\ d+)$" )
62+ public static void makeRequestWithPathParameter (String requestType , String endpoint , int pathParam ) {
63+ response = requestType .equals ("GET" ) ?
64+ RequestHelpers .sendGetRequestTo (endpoints .get (endpoint ) + "/" + pathParam ) :
65+ RequestHelpers .sendDeleteRequestTo (endpoints .get (endpoint ) + "/" + pathParam );
6266 responses .add (response );
6367 }
6468
65- @ When ("^I make a PUT request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
66- public static void makePutRequestWithEmptyBody (String endpoint ) {
67- response = RequestHelpers .sendPutRequestTo (endpoints .get (endpoint ), "{}" );
69+ @ When ("^I make a (POST|PUT) request with an empty body to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
70+ public static void makeRequestWithEmptyBody (String requestType , String endpoint ) {
71+ response = requestType .equals ("POST" ) ?
72+ RequestHelpers .sendPostRequestTo (endpoints .get (endpoint ), "{}" ) :
73+ RequestHelpers .sendPutRequestTo (endpoints .get (endpoint ), "{}" );
6874 responses .add (response );
6975 }
7076
71- @ When ("^I make a POST request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
72- public static void makePostRequestWithEmptyBody (String endpoint ) {
73- response = RequestHelpers .sendPostRequestTo (endpoints .get (endpoint ), "{}" );
77+ @ When ("^I make a (POST|PUT) request with an empty body to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (-?\\ d+)$" )
78+ public static void makeRequestWithEmptyBody (String requestType , String endpoint , int pathParam ) {
79+ response = requestType .equals ("POST" ) ?
80+ RequestHelpers .sendPostRequestTo (endpoints .get (endpoint ) + "/" + pathParam , "{}" ) :
81+ RequestHelpers .sendPutRequestTo (endpoints .get (endpoint ) + "/" + pathParam , "{}" );
7482 responses .add (response );
7583 }
7684
77- @ When ("^I make a DELETE request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint$" )
78- public static void makeDeleteRequest (String endpoint ) {
79- response = RequestHelpers .sendDeleteRequestTo (endpoints .get (endpoint ));
80- responses .add (response );
81- }
82-
83- @ When ("^I make a DELETE request to the (Posts|Comments|Albums|Photos|ToDos|Users) endpoint with a path parameter of (-?\\ d+)$" )
84- public static void makeDeleteRequestWithPathParameter (String endpoint , int pathParam ) {
85- response = RequestHelpers .sendDeleteRequestTo (endpoints .get (endpoint ) + "/" + pathParam );
86- responses .add (response );
87- }
8885
8986
9087 @ Then ("the response has a status code of {int}" )
0 commit comments