Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added example code to test post request with Java records #81

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -->
Loading