-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example code to test post request with Java records (#81)
- Loading branch information
1 parent
206f79d
commit 1db3cdc
Showing
2 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package in.reqres; | ||
|
||
|
||
import io.restassured.http.ContentType; | ||
import org.testng.annotations.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
public class TestPostWithRecords { | ||
public record UserData( String name, String job) { } | ||
private static final String URL = "https://reqres.in"; | ||
|
||
@Test | ||
public void testCreateUser() { | ||
|
||
UserData userData = new UserData("Faisal", "QA"); | ||
|
||
String response = given ().contentType (ContentType.JSON) | ||
.body (userData) | ||
.when () | ||
.post (URL + "/api/users") | ||
.then () | ||
.assertThat () | ||
.statusCode (201).extract().response().asString(); | ||
|
||
System.out.println(response); | ||
} | ||
|
||
|
||
|
||
} |
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