use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class GivenWhenThenResponseSpecITest method simple_given_when_then_works.
@Test
public void simple_given_when_then_works() {
exception.expect(AssertionError.class);
exception.expectMessage("2 expectations failed.\n" + "Expected status code <201> but was <200>.\n" + "\n" + "JSON path greeting doesn't match.\n" + "Expected: Greetings John Doo\n" + " Actual: Greetings John Doe");
ResponseSpecification specification = new ResponseSpecBuilder().expectStatusCode(201).expectBody("greeting", equalTo("Greetings John Doo")).build();
given().param("firstName", "John").param("lastName", "Doe").when().get("/greet").then().spec(specification);
}
use of io.restassured.specification.ResponseSpecification 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.specification.ResponseSpecification 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.specification.ResponseSpecification 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.specification.ResponseSpecification in project sonar-java by SonarSource.
the class AssertionsInTestsCheckTest method test_spec.
@Test
public void test_spec() {
// Compliant
ResponseSpecification spec = new ResponseSpecBuilder().expectStatusCode(200).expectBody("content", equalTo("Hello, Johan!")).build();
RestAssured.given().get("http://url.com").then().spec(spec);
}
Aggregations