-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Ensure query parameters are added to requests with a body (#1634)
* Fix: Ensure query parameters are added to requests with a body * test file * deleted @test from testPostRequest.java * Fix: Ensure query parameters are added to requests with a body --------- Co-authored-by: Kyrillos Nageh Abdelnour Flamon <kyrillosnageh@3ddx.com>
- Loading branch information
1 parent
3c6b582
commit 1178c36
Showing
2 changed files
with
124 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.shaft.api; | ||
|
||
import com.shaft.api.RestActions; | ||
import com.shaft.driver.SHAFT; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class testPostRequest { | ||
SHAFT.API api = new SHAFT.API("http://localhost:5000"); | ||
String body = """ | ||
{ | ||
"title": "New Course 1", | ||
"description": "Full description of the new course in Arabic" | ||
} | ||
"""; | ||
List<List<Object>> parameters = Arrays.asList(Arrays.asList("access_key", "your-access-key")); | ||
|
||
// @Test | ||
public void PostRequest(){ | ||
|
||
api.post("/courses") | ||
.setRequestBody(body) | ||
.setParameters(parameters, RestActions.ParametersType.QUERY) | ||
.setContentType("application/json") | ||
.perform(); | ||
|
||
/* | ||
api.get("/courses") | ||
.setParameters(parameters, RestActions.ParametersType.QUERY) | ||
.setContentType("application/json") | ||
.perform(); | ||
*/ | ||
String body = api.getResponseBody(); | ||
int st =api.getResponse().statusCode(); | ||
Assert.assertEquals(st,201); | ||
|
||
SHAFT.Report.log(">>>>>>>>>>>>> Test result" +body); | ||
} | ||
} |