use of io.restassured.builder.RequestSpecBuilder 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"));
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class AcceptHeaderITest method accept_method_from_spec_is_set_to_request_when_specified_as_content_type.
@Test
public void accept_method_from_spec_is_set_to_request_when_specified_as_content_type() {
RequestSpecification spec = new RequestSpecBuilder().setAccept(ContentType.JSON).build();
RestAssured.given().spec(spec).body("{ \"message\" : \"hello world\"}").when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class AcceptHeaderITest method accept_headers_are_merged_from_request_spec_and_request_when_configured_to.
@Test
public void accept_headers_are_merged_from_request_spec_and_request_when_configured_to() {
RequestSpecification spec = new RequestSpecBuilder().setAccept("text/jux").build();
final MutableObject<List<String>> headers = new MutableObject<List<String>>();
RestAssured.given().config(RestAssuredConfig.config().headerConfig(HeaderConfig.headerConfig().mergeHeadersWithName("Accept"))).accept(ContentType.JSON).spec(spec).body("{ \"message\" : \"hello world\"}").filter(new Filter() {
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
headers.setValue(requestSpec.getHeaders().getValues("Accept"));
return ctx.next(requestSpec, responseSpec);
}
}).when().post("/jsonBodyAcceptHeader").then().body(equalTo("hello world"));
assertThat(headers.getValue(), contains("application/json, application/javascript, text/javascript, text/json", "text/jux"));
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class SpecificationsDemoITest method demoRequestSpecification.
@Test
public void demoRequestSpecification() throws Exception {
final RequestSpecification books = new RequestSpecBuilder().addQueryParam("category", "books").addCookie("user", "admin").build();
given().specification(books).expect().body(equalTo("Catch 22")).when().get("/demoRequestSpecification");
}
use of io.restassured.builder.RequestSpecBuilder in project spring-cloud-netflix by spring-cloud.
the class AbstractDocumentationTests method spec.
private RequestSpecification spec(Object body, Filter... filters) {
RequestSpecBuilder builder = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation).snippets().withAdditionalDefaults(new WireMockSnippet()));
for (Filter filter : filters) {
builder = builder.addFilter(filter);
}
RequestSpecification spec = builder.setPort(this.port).build();
if (body != null) {
spec.contentType("application/json").body(body, new EurekaObjectMapper());
}
return spec;
}
Aggregations