From dd47e37cba175dc693b76511fa591d10c857b82d Mon Sep 17 00:00:00 2001 From: Anh Tester Date: Fri, 15 Dec 2023 01:27:13 +0700 Subject: [PATCH] =?UTF-8?q?Update=20b=C3=A0i=206=20-=20POJO=20class=20to?= =?UTF-8?q?=20JSON=20body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 9 ++ pom.xml | 55 ++++++++++++ .../Bai3_SendRequest_GET/DemoAddHeader.java | 31 +++++++ .../Bai3_SendRequest_GET/DemoAddParam.java | 39 +++++++++ .../DemoGivenWhenThen.java | 21 +++++ .../DemoVerifyUseAssertTestNG.java | 36 ++++++++ .../DemoVerifyUseJsonPath.java | 48 +++++++++++ .../DemoVerifyUseThenMethod.java | 35 ++++++++ .../Bai5_PhuongThucPOST/DemoPostMethod.java | 86 +++++++++++++++++++ .../anhtester/Bai6_POJO_JSON/DemoPOJO.java | 69 +++++++++++++++ .../Bai6_POJO_JSON/DemoPOJO_MultiLevel.java | 73 ++++++++++++++++ .../java/com/anhtester/model/BookingBody.java | 37 ++++++++ .../com/anhtester/model/BookingDates.java | 22 +++++ .../java/com/anhtester/model/LoginPOJO.java | 30 +++++++ .../com/anhtester/model/RegisterUserPOJO.java | 80 +++++++++++++++++ src/test/resources/login.json | 4 + 16 files changed, 675 insertions(+) create mode 100644 pom.xml create mode 100644 src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddHeader.java create mode 100644 src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddParam.java create mode 100644 src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoGivenWhenThen.java create mode 100644 src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseAssertTestNG.java create mode 100644 src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseJsonPath.java create mode 100644 src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseThenMethod.java create mode 100644 src/test/java/com/anhtester/Bai5_PhuongThucPOST/DemoPostMethod.java create mode 100644 src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO.java create mode 100644 src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO_MultiLevel.java create mode 100644 src/test/java/com/anhtester/model/BookingBody.java create mode 100644 src/test/java/com/anhtester/model/BookingDates.java create mode 100644 src/test/java/com/anhtester/model/LoginPOJO.java create mode 100644 src/test/java/com/anhtester/model/RegisterUserPOJO.java create mode 100644 src/test/resources/login.json diff --git a/.gitignore b/.gitignore index 2f43530..2fc9d21 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,12 @@ buildNumber.properties .project # JDT-specific (Eclipse Java Development Tools) .classpath +*.iml +.idea/ +reports/ +report/ +out/ +logs/ +*.log +*.avi +*.mp4 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cb376fe --- /dev/null +++ b/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.anhtester + RestAssuredTestNG2023 + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + + + + + org.testng + testng + 7.8.0 + + + + + io.rest-assured + rest-assured + 5.4.0 + + + + + org.slf4j + slf4j-api + 2.0.9 + + + + org.slf4j + slf4j-simple + 2.0.9 + + + + + com.google.code.gson + gson + 2.10.1 + + + + + \ No newline at end of file diff --git a/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddHeader.java b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddHeader.java new file mode 100644 index 0000000..ff28b2f --- /dev/null +++ b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddHeader.java @@ -0,0 +1,31 @@ +package com.anhtester.Bai3_SendRequest_GET; + +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; + +public class DemoAddHeader { + + @Test + public void testAddHeader(){ + + //Khai báo đối tượng request + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api"); + request.basePath("/users"); + //Add header theo yêu cầu, với cú pháp (key,value) + request.header("accept", "application/json"); + //request.header("", ""); + //request.accept("application/json"); + + Response response = request.when().get(); + + response.prettyPrint(); + + response.then().statusCode(200); + + } + +} diff --git a/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddParam.java b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddParam.java new file mode 100644 index 0000000..4d0e290 --- /dev/null +++ b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoAddParam.java @@ -0,0 +1,39 @@ +package com.anhtester.Bai3_SendRequest_GET; + +import io.restassured.http.ContentType; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; + +public class DemoAddParam { + + @Test + public void testUserByUserName() { + //Khai báo đối tượng request để thiết lập điều kiện đầu vào + //Dùng given() chỉ thị sự thiết lập sẵn điều kiện + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .basePath("/user") + .accept("application/json"); + + //Khai báo tham số đầu vào với hàm queryParam + request.queryParam("username", "anhtester2"); +// request.pathParam("", ""); +// request.formParam("", ""); + + Response response = request.when().get(); + response.prettyPrint(); + + response.then().statusCode(200); + response.then().statusLine("HTTP/1.1 200 OK"); + response.then().contentType(ContentType.JSON); + + response.then().body("response.username", equalTo("anhtester2")); + response.then().body("response.email", containsString("an2")); + } + +} diff --git a/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoGivenWhenThen.java b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoGivenWhenThen.java new file mode 100644 index 0000000..d3c9939 --- /dev/null +++ b/src/test/java/com/anhtester/Bai3_SendRequest_GET/DemoGivenWhenThen.java @@ -0,0 +1,21 @@ +package com.anhtester.Bai3_SendRequest_GET; + +import io.restassured.http.ContentType; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; + +public class DemoGivenWhenThen { + + @Test + public void testGetUsers(){ + System.out.println("testGetUsers"); + + given().baseUri("https://api.anhtester.com/api") + .accept("application/json") + .basePath("/users") + .when().get() + .then().statusCode(200).contentType(ContentType.JSON); + } + +} diff --git a/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseAssertTestNG.java b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseAssertTestNG.java new file mode 100644 index 0000000..a52a75f --- /dev/null +++ b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseAssertTestNG.java @@ -0,0 +1,36 @@ +package com.anhtester.Bai4_VerifyResponse; + +import io.restassured.response.Response; +import io.restassured.response.ResponseBody; +import io.restassured.specification.RequestSpecification; +import org.testng.Assert; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; + +public class DemoVerifyUseAssertTestNG { + @Test + public void testVerifyResponseUseAssertTestNG() { + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json"); + + int id = 1; //ID của book. Gắn vào sau path url luôn + + Response response = request.when().get("/book/" + id); + response.prettyPrint(); + + //Verify kết quả từ response với Assert trong TestNG + //Dùng class Assert chấm gọi 2 hàm chính là assertEquals và assertTrue + Assert.assertEquals(response.getStatusCode(), 200, "Status Code chưa đúng."); + Assert.assertEquals(response.getContentType(), "application/json", "Content Type chưa đúng."); + + //Khi lấy kết quả trong body thì cần dùng đối tượng class ResponseBody để lấy hết về kiểu String + //Khi đó chỉ có thể dùng hàm contains để so sánh chứa, vì không lấy được từng giá trị của từng key + ResponseBody body = response.getBody(); + Assert.assertEquals(body.asString().contains("Success"), true, "Message Success không tồn tại."); + + //Muốn lấy giá trị từng key trong JSON body để compare chính xác thì + //phải dùng hàm then() hoặc thư viện JsonPath + } +} diff --git a/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseJsonPath.java b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseJsonPath.java new file mode 100644 index 0000000..c06f9c5 --- /dev/null +++ b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseJsonPath.java @@ -0,0 +1,48 @@ +package com.anhtester.Bai4_VerifyResponse; + +import io.restassured.path.json.JsonPath; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.Assert; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; + +public class DemoVerifyUseJsonPath { + @Test + public void testVerifyResponseUseAssertTestNG() { + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json"); + + int id = 1; //ID của book. Gắn vào sau path url luôn + + Response response = request.when().get("/book/" + id); + response.prettyPrint(); + + //Verify kết quả từ response với Assert trong TestNG + //Dùng class Assert chấm gọi 2 hàm chính là assertEquals và assertTrue + Assert.assertEquals(response.getStatusCode(), 200, "Status Code chưa đúng."); + Assert.assertEquals(response.getContentType(), "application/json", "Content Type chưa đúng."); + + //Muốn lấy giá trị từng key trong JSON body để compare chính xác thì dùng JsonPath + JsonPath jsonPath = response.jsonPath(); //Lưu hết body vào đối tượng jsonPath + + //Truy xuất giá trị theo key hoặc đường dẫn xpath theo cấp bậc + String name = jsonPath.get("response.name"); + System.out.println("Name: " + name); + //Dùng Assert của TestNG để verify + Assert.assertEquals(name.contains("Phương Nam"), true, "Name không tồn tại."); + Assert.assertEquals(name, "Đất Rừng Phương Nam", "Name không tồn tại."); + //Khi lấy trực tiếp giá trị từ jsonPath thì cần toString + //và phải chuyển số về sạng chuỗi để so sánh + Assert.assertEquals(jsonPath.get("response.price").toString(), "12000", "Price không đúng."); + Assert.assertEquals(Integer.parseInt(jsonPath.get("response.price").toString()), 12000, "Price không đúng."); + + //Lấy đường dẫn path thứ 2 trong mảng của object "image" + //Index bắt đầu tính từ 0 + String imagePath2 = jsonPath.get("response.image[1].path"); + System.out.println(imagePath2); + Assert.assertTrue(imagePath2.contains("public/images/TwSX1W1"), "Không đúng hình ảnh thứ 2."); + } +} diff --git a/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseThenMethod.java b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseThenMethod.java new file mode 100644 index 0000000..ba99577 --- /dev/null +++ b/src/test/java/com/anhtester/Bai4_VerifyResponse/DemoVerifyUseThenMethod.java @@ -0,0 +1,35 @@ +package com.anhtester.Bai4_VerifyResponse; + +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; + +public class DemoVerifyUseThenMethod { + + @Test + public void testVerifyResponseUseThenMethod() { + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json"); + + int id = 1; //ID của book. Gắn vào sau path url luôn + + Response response = request.when().get("/book/" + id); + response.prettyPrint(); + + //Verify kết quả từ response với hàm then() + response.then().statusCode(200); + response.then().contentType("application/json"); + //Đối với body thì cần điền cấu trúc theo xpath từ json + //Hàm equalTo thuộc thư viện org.hamcrest.Matchers + response.then().body("response.name", equalTo("Đất Rừng Phương Nam")); + response.then().body("response.price", equalTo(1200)); + //Dùng vị trí index để lấy thứ tự phần tử trong JSON body. Tính từ 0 + response.then().body("response.image[0].path", containsString("public/images/1avh0VncWc")); + } + +} diff --git a/src/test/java/com/anhtester/Bai5_PhuongThucPOST/DemoPostMethod.java b/src/test/java/com/anhtester/Bai5_PhuongThucPOST/DemoPostMethod.java new file mode 100644 index 0000000..61dacc1 --- /dev/null +++ b/src/test/java/com/anhtester/Bai5_PhuongThucPOST/DemoPostMethod.java @@ -0,0 +1,86 @@ +package com.anhtester.Bai5_PhuongThucPOST; + +import io.restassured.http.ContentType; +import io.restassured.path.json.JsonPath; +import io.restassured.response.Response; +import io.restassured.response.ResponseBody; +import io.restassured.specification.RequestSpecification; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.io.File; + +import static io.restassured.RestAssured.given; + +public class DemoPostMethod { + @Test + public void testLoginUser() { + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json") + .contentType("application/json") + .body("{\n" + + " \"username\": \"anhtester4\",\n" + + " \"password\": \"Demo@123\"\n" + + "}"); + + //Thực hiện phương thức post() để gửi dữ liệu đi + Response response = request.when().post("/login"); + response.prettyPrint(); + + response.then().statusCode(200); + + String token = response.getBody().path("token").toString(); + System.out.println(token); + } + + @Test + public void testRegisterUser() { + + String username = "anhtester12"; + String firstName = "Anh"; + String lastName = "Tester"; + String email = username + "@email.com"; + String password = "Demo@123"; + String phone = "0123456789"; + int userStatus = 1; + + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json") + .contentType("application/json") + .body("{\n" + + " \"username\": \" " + username + "\",\n" + + " \"firstName\": \"" + firstName + "\",\n" + + " \"lastName\": \"" + lastName + "\",\n" + + " \"email\": \"" + username + "@email.com\",\n" + + " \"password\": \"" + password + "\",\n" + + " \"phone\": \"" + phone + "\",\n" + + " \"userStatus\": " + userStatus + "\n" + + "}"); + + //Thực hiện phương thức post() để gửi dữ liệu đi + Response response = request.when().post("/register"); + response.prettyPrint(); + response.then().statusCode(200); + + //Verify Response + response.then().contentType(ContentType.JSON); + + //Cách 1 + ResponseBody responseBody = response.getBody(); + + //Cách 2 (ưu tiên cách 2) + JsonPath jsonPath = response.jsonPath(); + + Assert.assertEquals(jsonPath.get("response.username"), username, "The username not match."); + Assert.assertEquals(responseBody.path("response.firstName"), firstName, "The firstName not match."); + Assert.assertEquals(responseBody.path("response.lastName"), lastName, "The lastName not match."); + Assert.assertEquals(responseBody.path("response.email"), email, "The email not match."); + //Assert.assertEquals(responseBody.path("response.password"), password, "The password not match."); + Assert.assertEquals(responseBody.path("response.phone"), phone, "The phone not match."); + Assert.assertEquals(Integer.parseInt(responseBody.path("response.userStatus").toString()), userStatus, "The userStatus not match."); + Assert.assertTrue(responseBody.path("response.id").toString().length() > 0, "The ID not exsiting."); + + } +} diff --git a/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO.java b/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO.java new file mode 100644 index 0000000..587f0d8 --- /dev/null +++ b/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO.java @@ -0,0 +1,69 @@ +package com.anhtester.Bai6_POJO_JSON; + +import com.anhtester.model.LoginPOJO; +import com.anhtester.model.RegisterUserPOJO; +import com.google.gson.Gson; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.Assert; +import org.testng.annotations.Test; + +import static io.restassured.RestAssured.given; + +public class DemoPOJO { + @Test + public void testLoginUser() { + + //Khởi tạo giá trị cho các fields thông qua hàm xây dựng + LoginPOJO loginPOJO = new LoginPOJO("anhtester4", "Demo@123"); + + //Dùng thư viện Gson để chuyển class POJO về dạng JSON + Gson gson = new Gson(); + + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json") + .contentType("application/json") + .body(gson.toJson(loginPOJO)); //Tự chuyển từ POJO class sang dạng JSON data + + Response response = request.when().post("/login"); + response.prettyPrint(); + + response.then().statusCode(200); + + String token = response.getBody().path("token"); + System.out.println(token); + } + + @Test + public void testRegisterUser() { + + //Khởi tạo giá trị cho các fields thông qua hàm xây dựng + RegisterUserPOJO registerUserPOJO = new RegisterUserPOJO(); + registerUserPOJO.setUsername("myduyen2"); + registerUserPOJO.setPassword("Demo@123"); + registerUserPOJO.setFirstName("Lê Thị"); + registerUserPOJO.setLastName("Mỹ Duyên"); + registerUserPOJO.setEmail("myduyen2@email.com"); + registerUserPOJO.setPhone("0123456789"); + registerUserPOJO.setUserStatus(1); + + //Dùng thư viện Gson để chuyển class POJO về dạng JSON + Gson gson = new Gson(); + + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json") + .contentType("application/json") + .body(gson.toJson(registerUserPOJO)); + + Response response = request.when().post("/register"); + response.prettyPrint(); + + response.then().statusCode(200); + + String message = response.getBody().path("message"); + Assert.assertEquals(message, "Success", "The message not match."); + } + +} diff --git a/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO_MultiLevel.java b/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO_MultiLevel.java new file mode 100644 index 0000000..48c1600 --- /dev/null +++ b/src/test/java/com/anhtester/Bai6_POJO_JSON/DemoPOJO_MultiLevel.java @@ -0,0 +1,73 @@ +package com.anhtester.Bai6_POJO_JSON; + +import com.anhtester.model.BookingBody; +import com.anhtester.model.BookingDates; +import com.google.gson.Gson; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; +import org.testng.annotations.Test; + +import java.io.File; + +import static io.restassured.RestAssured.given; + +public class DemoPOJO_MultiLevel { + @Test + public void testCreateBooking() { + + String baseUri = "https://restful-booker.herokuapp.com"; + + RequestSpecification request = given(); + request.baseUri(baseUri); + request.header("Accept", "application/json") + .header("Content-Type", "application/json"); + + //Khởi tạo 2 class POJO + BookingBody bookingBody = new BookingBody(); + BookingDates bookingDates = new BookingDates(); + + //Set giá trị cho các fields không chứa cấp bậc + bookingBody.setFirstname("Anh"); + bookingBody.setLastname("Tester 02"); + bookingBody.setTotalprice(120); + bookingBody.setDepositpaid(false); + bookingBody.setAdditionalneeds("Automation"); + + //Set giá trị cho 2 fields con từ class POJO phụ + bookingDates.setCheckin("2023-12-15"); + bookingDates.setCheckout("2023-12-30"); + + //Set giá trị cho field Cha với 2 thông số từ fields Con + bookingBody.setBookingdates(bookingDates); + + Gson gson = new Gson(); + + //Convert POJO to JSON + request.body(gson.toJson(bookingBody)); + + Response response = request.post("/booking"); + response.prettyPrint(); + response.then().statusCode(200); + } + + @Test + public void testLoginUser() { + + String filePath = "src/test/resources/login.json"; + + RequestSpecification request = given(); + request.baseUri("https://api.anhtester.com/api") + .accept("application/json") + .contentType("application/json") + .body(new File(filePath)); + + //Thực hiện phương thức post() để gửi dữ liệu đi + Response response = request.when().post("/login"); + response.prettyPrint(); + + response.then().statusCode(200); + + String token = response.getBody().path("token").toString(); + System.out.println(token); + } +} diff --git a/src/test/java/com/anhtester/model/BookingBody.java b/src/test/java/com/anhtester/model/BookingBody.java new file mode 100644 index 0000000..8725a85 --- /dev/null +++ b/src/test/java/com/anhtester/model/BookingBody.java @@ -0,0 +1,37 @@ +package com.anhtester.model; + +public class BookingBody { + private String firstname; + private String lastname; + private int totalprice; + private boolean depositpaid; + + //Kiểu dữ liệu là class BookingDates + private BookingDates bookingdates; + + private String additionalneeds; + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public void setTotalprice(int totalprice) { + this.totalprice = totalprice; + } + + public void setDepositpaid(boolean depositpaid) { + this.depositpaid = depositpaid; + } + + public void setBookingdates(BookingDates bookingdates) { + this.bookingdates = bookingdates; + } + + public void setAdditionalneeds(String additionalneeds) { + this.additionalneeds = additionalneeds; + } +} diff --git a/src/test/java/com/anhtester/model/BookingDates.java b/src/test/java/com/anhtester/model/BookingDates.java new file mode 100644 index 0000000..1a0a5a3 --- /dev/null +++ b/src/test/java/com/anhtester/model/BookingDates.java @@ -0,0 +1,22 @@ +package com.anhtester.model; + +public class BookingDates { + private String checkin; + private String checkout; + + public String getCheckin() { + return checkin; + } + + public String getCheckout() { + return checkout; + } + + public void setCheckin(String checkin) { + this.checkin = checkin; + } + + public void setCheckout(String checkout) { + this.checkout = checkout; + } +} diff --git a/src/test/java/com/anhtester/model/LoginPOJO.java b/src/test/java/com/anhtester/model/LoginPOJO.java new file mode 100644 index 0000000..8e27e31 --- /dev/null +++ b/src/test/java/com/anhtester/model/LoginPOJO.java @@ -0,0 +1,30 @@ +package com.anhtester.model; + +public class LoginPOJO { + private String username; + private String password; + + public LoginPOJO(String username, String password) { + this.username = username; + this.password = password; + } + + public LoginPOJO() { + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/test/java/com/anhtester/model/RegisterUserPOJO.java b/src/test/java/com/anhtester/model/RegisterUserPOJO.java new file mode 100644 index 0000000..2f6dc61 --- /dev/null +++ b/src/test/java/com/anhtester/model/RegisterUserPOJO.java @@ -0,0 +1,80 @@ +package com.anhtester.model; + +public class RegisterUserPOJO { + private String username; + private String firstName; + private String lastName; + private String email; + private String password; + private String phone; + private int userStatus; + + public RegisterUserPOJO(String username, String firstName, String lastName, String email, String password, String phone, int userStatus) { + this.username = username; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.password = password; + this.phone = phone; + this.userStatus = userStatus; + } + + public RegisterUserPOJO() { + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public int getUserStatus() { + return userStatus; + } + + public void setUserStatus(int userStatus) { + this.userStatus = userStatus; + } +} diff --git a/src/test/resources/login.json b/src/test/resources/login.json new file mode 100644 index 0000000..b81e84b --- /dev/null +++ b/src/test/resources/login.json @@ -0,0 +1,4 @@ +{ + "username": "anhtester4", + "password": "Demo@123" +} \ No newline at end of file