Search in sources :

Example 16 with ResponseSpecBuilder

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

the class SpecificationBuilderITest method responseSpecificationCanExpectContentWithArgs.

@Test
public void responseSpecificationCanExpectContentWithArgs() throws Exception {
    final ResponseSpecification spec = new ResponseSpecBuilder().rootPath("store.book[%d]").expectContent("author", withArgs(0), equalTo("Nigel Rees")).build();
    expect().spec(spec).content("title", withArgs(1), equalTo("Sword of Honour")).when().get("/jsonStore");
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Example 17 with ResponseSpecBuilder

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

the class SpecificationBuilderITest method responseSpecificationCanExpectBodyWithArgs.

@Test
public void responseSpecificationCanExpectBodyWithArgs() throws Exception {
    final ResponseSpecification spec = new ResponseSpecBuilder().rootPath("store.book[%d]").expectBody("author", withArgs(0), equalTo("Nigel Rees")).build();
    expect().spec(spec).body("title", withArgs(1), equalTo("Sword of Honour")).when().get("/jsonStore");
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Example 18 with ResponseSpecBuilder

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

the class XMLGetITest method supportsRegisteringCustomParserForAGivenMimeTypeUsingResponseSpec.

@Test
public void supportsRegisteringCustomParserForAGivenMimeTypeUsingResponseSpec() throws Exception {
    final String mimeType = "application/something-custom";
    final ResponseSpecification specification = new ResponseSpecBuilder().registerParser(mimeType, Parser.XML).build();
    RestAssured.expect().specification(specification).and().body("body.message", equalTo("Custom mime-type")).when().get("/customMimeType");
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Example 19 with ResponseSpecBuilder

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

the class ResponseTimeITest method response_time_validation_can_be_specified_in_specification.

@Test
public void response_time_validation_can_be_specified_in_specification() {
    ResponseSpecification spec = new ResponseSpecBuilder().expectResponseTime(lessThanOrEqualTo(3000L)).build();
    given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(spec);
}
Also used : ResponseSpecBuilder(io.restassured.builder.ResponseSpecBuilder) ResponseSpecification(io.restassured.specification.ResponseSpecification) Test(org.junit.Test)

Example 20 with ResponseSpecBuilder

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

the class ResponseTimeITest method response_time_validation_can_fail_when_specified_in_specification.

@Test
public void response_time_validation_can_fail_when_specified_in_specification() {
    exception.expect(AssertionError.class);
    exception.expectMessage("Expected response time was not a value less than or equal to <3L> nanoseconds, was");
    ResponseSpecification spec = new ResponseSpecBuilder().expectResponseTime(lessThanOrEqualTo(3L), NANOSECONDS).build();
    given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(spec);
}
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