Challenge 2 rest-assured

  • Cách 1: Dùng Map<String, Object>
Map<String, Object> payload = new HashMap<>();
payload.put("name", "honda");
payload.put("number", 100);
//payload.put("number", 10.5);

RestAssured.given().log().all()
        .contentType(ContentType.JSON)
        .body(payload)
        .get("http://postman-echo.com/post")
        .prettyPrint();

Cách 2: Dùng POJO

Car payload = new Car("honda", 100);
//Car payload = new Car("honda", 10.5);

RestAssured.given().log().all()
        .contentType(ContentType.JSON)
        .body(payload)
        .get("http://postman-echo.com/post")
        .prettyPrint();
public class Car{
    public String name;
    public Object number;

    public Car(String name, Object number) {
        this.name = name;
        this.number = number;
    }
}
0 0 votes
Đánh giá challenge
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments