Level 6 · Core automation
REST Assured Automation Hub
Everything from a first GET request to a parallel, CI-ready API framework — with the code you can paste into a real project.
GET with query & path params
Keep the URI templated so logs and reports stay readable.
java
1given().spec(SPEC)2 .pathParam("id", 7)3 .queryParam("include", "items")4.when().get("/orders/{id}")5.then().statusCode(200)6 .body("id", equalTo(7));POST with a POJO body
Serialize a POJO rather than hand-writing JSON strings.
java
1Order payload = Order.builder()2 .customerId(42)3 .items(List.of(new Item("SKU-1", 2)))4 .build();5 6int id = given().spec(SPEC).body(payload)7 .when().post("/orders")8 .then().statusCode(201)9 .extract().path("id");PUT vs PATCH
PUT replaces the resource; PATCH sends only the diff. Assert untouched fields on PATCH.
java
1// PUT — full replacement2given().spec(SPEC).body(fullOrder).when().put("/orders/7").then().statusCode(200);3 4// PATCH — partial update, verify other fields survive5given().spec(SPEC).body(Map.of("status", "SHIPPED"))6.when().patch("/orders/7")7.then().statusCode(200)8 .body("status", equalTo("SHIPPED"))9 .body("customer.email", equalTo(originalEmail));DELETE and verify
Always follow a delete with a GET expecting 404.
java
1given().spec(SPEC).when().delete("/orders/7").then().statusCode(204);2given().spec(SPEC).when().get("/orders/7").then().statusCode(404);