Search in sources :

Example 21 with ResponseSpecification

use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.

the class JSONGetITest method specificationSyntax.

@Test
public void specificationSyntax() throws Exception {
    final RequestSpecification requestSpecification = with().parameters("firstName", "John", "lastName", "Doe");
    final ResponseSpecification responseSpecification = expect().body("greeting", equalTo("Greetings John Doe"));
    given(requestSpecification, responseSpecification).get("/greet");
}
Also used : ResponseSpecification(io.restassured.specification.ResponseSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) Test(org.junit.Test)

Example 22 with ResponseSpecification

use of io.restassured.specification.ResponseSpecification in project rest-assured by rest-assured.

the class JSONPostITest method requestContentType.

@Test
public void requestContentType() throws Exception {
    final RequestSpecification requestSpecification = given().contentType(ContentType.URLENC).with().parameters("firstName", "John", "lastName", "Doe");
    final ResponseSpecification responseSpecification = expect().contentType(ContentType.JSON).and().body("greeting", equalTo("Greetings John Doe"));
    given(requestSpecification, responseSpecification).post("/greet");
}
Also used : ResponseSpecification(io.restassured.specification.ResponseSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) Test(org.junit.Test)

Example 23 with ResponseSpecification

use of io.restassured.specification.ResponseSpecification in project vertigo by KleeGroup.

the class WebServiceManagerTest method doPaginedSearch.

private String doPaginedSearch(final Map<String, Object> criteriaContact, final Integer top, final Integer skip, final String sortFieldName, final Boolean sortDesc, final String listServerToken, final int expectedSize, final String firstContactName, final String lastContactName, final boolean isAuto) {
    final RequestSpecification given = given().filter(loggedSessionFilter);
    final String wsUrl = isAuto ? "/test/_searchAutoPagined" : "/test/_searchQueryPagined";
    if (top != null) {
        given.queryParam("top", top);
    }
    if (skip != null) {
        given.queryParam("skip", skip);
    }
    if (sortFieldName != null) {
        given.queryParam("sortFieldName", sortFieldName);
    }
    if (sortDesc != null) {
        given.queryParam("sortDesc", sortDesc);
    }
    if (listServerToken != null) {
        given.queryParam("listServerToken", listServerToken);
    }
    ResponseSpecification responseSpecification = given.body(criteriaContact).expect().body("size()", Matchers.equalTo(expectedSize));
    if (expectedSize > 0) {
        responseSpecification = responseSpecification.body("get(0).name", Matchers.equalTo(firstContactName)).body("get(" + (expectedSize - 1) + ").name", Matchers.equalTo(lastContactName));
    }
    final String newListServerToken = responseSpecification.statusCode(HttpStatus.SC_OK).when().post(wsUrl).header("listServerToken");
    return newListServerToken;
}
Also used : ResponseSpecification(io.restassured.specification.ResponseSpecification) RequestSpecification(io.restassured.specification.RequestSpecification)

Aggregations

ResponseSpecification (io.restassured.specification.ResponseSpecification)23 Test (org.junit.Test)20 ResponseSpecBuilder (io.restassured.builder.ResponseSpecBuilder)14 RequestSpecification (io.restassured.specification.RequestSpecification)5 Matchers.containsString (org.hamcrest.Matchers.containsString)2 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)2 Cookies (io.restassured.http.Cookies)1 Response (io.restassured.response.Response)1 StringWriter (java.io.StringWriter)1 InetSocketAddress (java.net.InetSocketAddress)1 HttpResponse (org.apache.http.HttpResponse)1 MockRequestMatcher (org.apache.knox.test.mock.MockRequestMatcher)1 Template (org.apache.velocity.Template)1 VelocityContext (org.apache.velocity.VelocityContext)1 VelocityEngine (org.apache.velocity.app.VelocityEngine)1 ClasspathResourceLoader (org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader)1 Matcher (org.hamcrest.Matcher)1