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

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

Introduction

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

Prototype

String getContentAsString();

Source Link

Document

Returns the content of the response as a String .

Usage

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

@Test
public void convers_response() {
    final ClientResponse clientResponse = Mocks.clientResponseBuilder().status(200)
            .header("X-Response-Header1", "SomeValue1").header("X-Response-Header2", "SomeValue2")
            .requestContext(Mocks.clientRequestBuilder()
                    .configProp(RESPONSE_BODY_KEY, "Testing".getBytes(StandardCharsets.UTF_8)).build())
            .build();//from  w  ww  . j  a v  a  2 s .c  o m
    final OperationResponse response = new JerseyResponseConverter().convert(clientResponse);
    assertThat(response.getContentAsString(), is("Testing"));
    assertThat(response.getStatus().value(), is(200));
    assertThat(response.getHeaders().getFirst("X-Response-Header1"), is("SomeValue1"));
    assertThat(response.getHeaders().getFirst("X-Response-Header2"), is("SomeValue2"));
}