From c23ab3edb74b5e408f7a00853e159ed892ed7957 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Mon, 18 Sep 2023 12:07:12 +0530 Subject: [PATCH] added example code to test post request with Java records --- .../java/in/reqres/TestPostWithRecords.java | 31 +++++++++++++++++++ test-suite/reqrestestsuite.xml | 5 +++ 2 files changed, 36 insertions(+) create mode 100644 src/test/java/in/reqres/TestPostWithRecords.java diff --git a/src/test/java/in/reqres/TestPostWithRecords.java b/src/test/java/in/reqres/TestPostWithRecords.java new file mode 100644 index 0000000..819ad91 --- /dev/null +++ b/src/test/java/in/reqres/TestPostWithRecords.java @@ -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); + } + + + +} diff --git a/test-suite/reqrestestsuite.xml b/test-suite/reqrestestsuite.xml index 3e2239b..8391f4b 100644 --- a/test-suite/reqrestestsuite.xml +++ b/test-suite/reqrestestsuite.xml @@ -96,4 +96,9 @@ + + + + + \ No newline at end of file