Skip to content

Commit

Permalink
added example code to test post request with Java records (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfaisalkhatri authored Sep 18, 2023
1 parent 206f79d commit 1db3cdc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/java/in/reqres/TestPostWithRecords.java
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);
}



}
5 changes: 5 additions & 0 deletions test-suite/reqrestestsuite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@
<class name="in.reqres.TestDelayedAPIWithAwaitility"/>
</classes>
</test>
<test name="Post Request Example with Java records">
<classes>
<class name="in.reqres.TestPostWithRecords"/>
</classes>
</test>
</suite> <!-- Suite -->

0 comments on commit 1db3cdc

Please sign in to comment.