December 2019
Intermediate to advanced
314 pages
6h 51m
English
Our basic Test class assumes that we already have a couple of Customer objects available. Therefore, once we verify their count with a GET request, we will test all CRUD operations on the Orders subordinate entity, as illustrated in the following code:
// Test GETgiven() .when().get("/customers") .then() .statusCode(200) .body("$.size()", is(2));// Create a JSON Object for the OrderJsonObject objOrder = Json.createObjectBuilder() .add("item", "bike") .add("price", new Long(100)) .build();// Test POST Order for Customer #1given() .contentType("application/json") .body(objOrder.toString()) .when() .post("/orders/1") .then() .statusCode(201);// Create new JSON for Order #1objOrder = Json.createObjectBuilder() .add("id", ...
Read now
Unlock full access