use of io.restassured.specification.ResponseSpecification in project sonar-java by SonarSource.
the class AssertionsInTestsCheckTest method test_specification.
@Test
public void test_specification() {
// Compliant
ResponseSpecification spec = new ResponseSpecBuilder().expectStatusCode(200).expectBody("content", equalTo("Hello, Johan!")).build();
RestAssured.given().get("http://url.com").then().specification(spec);
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class JSONGetITest method contentTypeSpecification.
@Test
public void contentTypeSpecification() throws Exception {
final RequestSpecification requestSpecification = given().contentType(ContentType.TEXT).with().parameters("firstName", "John", "lastName", "Doe");
final ResponseSpecification responseSpecification = expect().contentType(ContentType.JSON).and().body("greeting", equalTo("Greetings John Doe"));
given(requestSpecification, responseSpecification).get("/greet");
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class JSONGetITest method contentTypeSpecificationWithHamcrestMatcher.
@Test
public void contentTypeSpecificationWithHamcrestMatcher() throws Exception {
final RequestSpecification requestSpecification = given().contentType(ContentType.TEXT).with().parameters("firstName", "John", "lastName", "Doe");
final ResponseSpecification responseSpecification = expect().contentType(equalTo("application/json;charset=utf-8")).and().body("greeting", equalTo("Greetings John Doe"));
given(requestSpecification, responseSpecification).get("/greet");
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method mergesStaticallyDefinedResponseSpecificationsCorrectly.
@Test
public void mergesStaticallyDefinedResponseSpecificationsCorrectly() throws Exception {
RestAssured.responseSpecification = new ResponseSpecBuilder().expectCookie("Cookie1", "Value1").build();
ResponseSpecification reqSpec1 = new ResponseSpecBuilder().expectCookie("Cookie2", "Value2").build();
ResponseSpecification reqSpec2 = new ResponseSpecBuilder().expectCookie("Cookie3", "Value3").build();
try {
Cookies cookies = given().cookie("Cookie1", "Value1").cookie("Cookie2", "Value2").when().get("/reflect").then().assertThat().spec(reqSpec1).extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie2"), is(true));
cookies = given().cookie("Cookie1", "Value1").cookie("Cookie3", "Value3").when().get("/reflect").then().assertThat().spec(reqSpec2).extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie3"), is(true));
} finally {
RestAssured.reset();
}
}
use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.
the class SpecificationBuilderITest method expectingSpecificationMergesTheCurrentSpecificationWithTheSuppliedOne.
@Test
public void expectingSpecificationMergesTheCurrentSpecificationWithTheSuppliedOne() throws Exception {
final ResponseSpecBuilder builder = new ResponseSpecBuilder();
builder.expectBody("store.book.size()", is(4)).expectStatusCode(200);
final ResponseSpecification responseSpecification = builder.build();
expect().specification(responseSpecification).body("store.book[0].author", equalTo("Nigel Rees")).when().get("/jsonStore");
}
Aggregations