Example usage for org.springframework.restdocs.operation OperationRequest getContentAsString

List of usage examples for org.springframework.restdocs.operation OperationRequest getContentAsString

Introduction

In this page you can find the example usage for org.springframework.restdocs.operation OperationRequest getContentAsString.

Prototype

String getContentAsString();

Source Link

Document

Returns the content of the request as a String .

Usage

From source file:io.github.restdocsext.jersey.JerseyRequestConverterTest.java

@Test
public void convert_json_request() {
    final ClientRequest clientRequest = Mocks.clientRequestBuilder().method("POST")
            .contentType(MediaType.APPLICATION_JSON_TYPE).configProp(REQUEST_BODY_KEY, "{}".getBytes())
            .header("X-Request-Header", "SomeValue").uri(URI.create("http://localhost/api/?a=alpha&b=bravo"))
            .build();/*ww w  .j  av a  2s  .c  o m*/
    final OperationRequest request = new JerseyRequestConverter().convert(clientRequest);
    assertThat(request.getMethod(), is(HttpMethod.POST));
    assertThat(request.getParameters().getFirst("a"), is("alpha"));
    assertThat(request.getParameters().getFirst("b"), is("bravo"));
    assertThat(request.getHeaders().getFirst("X-Request-Header"), is("SomeValue"));
    assertThat(request.getContentAsString(), is("{}"));
}