1@BeforeAll
2 public static void init(){
3 RestAssured.baseURI = "http://........." ;
4 RestAssured.port = 8000 ;
5 RestAssured.basePath = "/api" ;
6 }
7String myBodyData = "{\n" +
8 " \"name\" : \"Adam\",\n" +
9 " \"gender\": \"Male\",\n" +
10 " \"phone\": 6234567890\n" +
11 "}" ;
12
13 System.out.println("myBodyData = " + myBodyData);
14
15 given()
16 .contentType( ContentType.JSON )
17 .body(myBodyData)
18 .log().all().
19 when()
20 .post("/spartans").
21 then()
22 .log().all()
23 .statusCode( is(201) )
24 .contentType(ContentType.JSON)
25 .body("success", is ("A Spartan is Born!"))
26 .body("data.name", is ("Adam"))
27 ;