Search in sources :

Example 21 with RequestSpecification

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

the class SpecificationBuilderITest method supportsMergingMultiValueQueryParametersUsingListWhenUsingRequestSpecBuilder.

@Test
public void supportsMergingMultiValueQueryParametersUsingListWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addQueryParam("list", asList("1", "2", "3")).build();
    given().spec(spec).expect().body("list", equalTo("1,2,3")).when().get("/multiValueParam");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 22 with RequestSpecification

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

the class SpecificationBuilderITest method supportsMergingFormParametersWhenUsingRequestSpecBuilder.

@Test
public void supportsMergingFormParametersWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addFormParam("lastName", "Doe").build();
    given().spec(spec).formParameter("firstName", "John").expect().body("greeting", Matchers.equalTo("Greetings John Doe")).when().put("/greetPut");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 23 with RequestSpecification

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

the class SpecificationBuilderITest method supportsSettingLoggingWhenUsingRequestSpecBuilder.

@Test
public void supportsSettingLoggingWhenUsingRequestSpecBuilder() throws Exception {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
    final RequestSpecification spec = new RequestSpecBuilder().setConfig(newConfig().logConfig(logConfig().defaultStream(captor))).and().log(ALL).build();
    given().spec(spec).pathParameter("firstName", "John").pathParameter("lastName", "Doe").when().get("/{firstName}/{lastName}").then().body("fullName", equalTo("John Doe"));
    assertThat(writer.toString(), equalTo("Request method:\tGET\nRequest URI:\thttp://localhost:8080/John/Doe\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\tfirstName=John\n\t\t\t\tlastName=Doe\nHeaders:\t\tAccept=*/*\nCookies:\t\t<none>\nMultiparts:\t\t<none>\nBody:\t\t\t<none>\n"));
}
Also used : PrintStream(java.io.PrintStream) StringWriter(java.io.StringWriter) RequestSpecification(io.restassured.specification.RequestSpecification) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 24 with RequestSpecification

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

the class SpecificationBuilderITest method supportsMergingPathParametersWhenUsingRequestSpecBuilder.

@Test
public void supportsMergingPathParametersWhenUsingRequestSpecBuilder() throws Exception {
    final RequestSpecification spec = new RequestSpecBuilder().addPathParam("lastName", "Doe").build();
    given().spec(spec).pathParameter("firstName", "John").expect().body("fullName", equalTo("John Doe")).when().get("/{firstName}/{lastName}");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 25 with RequestSpecification

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

the class AcceptHeaderITest method accept_method_from_spec_is_set_to_request_when_specified_as_string.

@Test
public void accept_method_from_spec_is_set_to_request_when_specified_as_string() {
    RequestSpecification spec = new RequestSpecBuilder().setAccept("application/json").build();
    RestAssured.given().spec(spec).body("{ \"message\" : \"hello world\"}").when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
}
Also used : FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)55 Test (org.junit.Test)47 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)40 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)7 SecurityTest (com.capgemini.ntc.security.SecurityTest)6 ResponseSpecification (io.restassured.specification.ResponseSpecification)5 Filter (io.restassured.filter.Filter)4 Parameters (junitparams.Parameters)4 FilterContext (io.restassured.filter.FilterContext)3 Header (io.restassured.http.Header)3 Response (io.restassured.response.Response)3 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)3 PrintStream (java.io.PrintStream)3 StringWriter (java.io.StringWriter)3 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)3 RestDocumentationFilter (org.springframework.restdocs.restassured3.RestDocumentationFilter)3 Headers (io.restassured.http.Headers)2 List (java.util.List)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1