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_using_time_unit.
@Test
public void response_time_validation_can_be_specified_in_specification_using_time_unit() {
ResponseSpecification spec = new ResponseSpecBuilder().expectResponseTime(lessThanOrEqualTo(3L), SECONDS).build();
given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(spec);
}
use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.
the class SpecificationBuilderITest method responseSpecificationSupportsMergingWithAnotherResponseSpecification.
@Test
public void responseSpecificationSupportsMergingWithAnotherResponseSpecification() throws Exception {
final ResponseSpecification specification = expect().body("store.book.size()", equalTo(4));
final ResponseSpecification built = new ResponseSpecBuilder().expectStatusCode(200).addResponseSpecification(specification).build();
expect().body("store.book.author", hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien")).spec(built).body("store.book[0].author", equalTo("Nigel Rees")).when().get("/jsonStore");
}
use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.
the class SpecificationsDemoITest method demoResponseSpecificationUsingGivenWhenThen.
@Test
public void demoResponseSpecificationUsingGivenWhenThen() throws Exception {
final ResponseSpecification spec = new ResponseSpecBuilder().expectStatusCode(200).expectBody("responseType", equalTo("simple")).build();
given().param("name", "John Doe").when().get("/demoResponseSpecification").then().specification(spec).body("firstName", is("John")).body("lastName", is("Doe"));
}
use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.
the class MockMvcStaticRequestAndResponseSpecTest method request_and_response_spec_can_be_defined_statically.
@Test
public void request_and_response_spec_can_be_defined_statically() {
RestAssuredMockMvc.requestSpecification = new MockMvcRequestSpecBuilder().addQueryParam("name", "Johan").build();
RestAssuredMockMvc.responseSpecification = new ResponseSpecBuilder().expectStatusCode(200).expectBody("content", equalTo("Hello, Johan!")).build();
try {
// When
RestAssuredMockMvc.given().standaloneSetup(new GreetingController()).when().get("/greeting").then().body("id", equalTo(1));
} finally {
RestAssuredMockMvc.reset();
}
}
use of io.restassured.builder.ResponseSpecBuilder in project rest-assured by rest-assured.
the class MockMvcStaticRequestAndResponseSpecTest method response_validation_fails_if_any_property_in_the_response_is_not_valid.
@Test
public void response_validation_fails_if_any_property_in_the_response_is_not_valid() {
RestAssuredMockMvc.requestSpecification = new MockMvcRequestSpecBuilder().addQueryParam("name", "Johan").build();
RestAssuredMockMvc.responseSpecification = new ResponseSpecBuilder().expectStatusCode(200).expectBody("content", equalTo("Hello, John!")).build();
exception.expect(AssertionError.class);
exception.expectMessage("1 expectation failed.\n" + "JSON path content doesn't match.\n" + "Expected: Hello, John!\n" + " Actual: Hello, Johan!");
try {
// When
RestAssuredMockMvc.given().standaloneSetup(new GreetingController()).when().get("/greeting").then().body("id", equalTo(1));
} finally {
RestAssuredMockMvc.reset();
}
}
Aggregations