Search in sources :

Example 21 with ResponseSpecBuilder

use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.

the class SpecificationBuilderITest method bodyExpectationsAreNotOverwritten.

@Test
public void bodyExpectationsAreNotOverwritten() throws Exception {
    final ResponseSpecBuilder builder = new ResponseSpecBuilder();
    builder.expectBody("store.book.size()", is(4)).expectStatusCode(200);
    final ResponseSpecification responseSpecification = builder.build();
    expect().body("store.book.author", hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien")).spec(responseSpecification).body("store.book[0].author", equalTo("Nigel Rees")).when().get("/jsonStore");
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Example 22 with ResponseSpecBuilder

use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.

the class SpecificationsDemoITest method demoResponseSpecification.

@Test
public void demoResponseSpecification() throws Exception {
    final ResponseSpecification spec = new ResponseSpecBuilder().expectStatusCode(200).expectBody("responseType", equalTo("simple")).build();
    given().param("name", "John Doe").expect().specification(spec).body("firstName", is("John")).body("lastName", is("Doe")).when().get("/demoResponseSpecification");
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Aggregations

ResponseSpecBuilder (io.restassured.builder.ResponseSpecBuilder)22 Test (org.junit.Test)22 ResponseSpecification (io.restassured.specification.ResponseSpecification)14 MockMvcRequestSpecBuilder (io.restassured.module.mockmvc.specification.MockMvcRequestSpecBuilder)4 LogConfig (io.restassured.config.LogConfig)3 GreetingController (io.restassured.module.mockmvc.http.GreetingController)3 PrintStream (java.io.PrintStream)3 StringWriter (java.io.StringWriter)3 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)3 PostController (io.restassured.module.mockmvc.http.PostController)2 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)1 Cookies (io.restassured.http.Cookies)1 RestAssuredMockMvcConfig (io.restassured.module.mockmvc.config.RestAssuredMockMvcConfig)1