@Test
public void shouldPostJson() throws IOException {

    when(requestMock.getMethod()).thenReturn("POST");
    when(requestMock.getPathInfo()).thenReturn("/postMethod");
    JsonObject requestObject = new JsonObject()
            .put("foo", "bar")
            .put("list", Arrays.asList("a", "b", "c"));
    when(requestMock.getReader())
        .thenReturn(new BufferedReader(new StringReader(requestObject.toIndentedJson(" "))));
    servlet.service(requestMock, responseMock);
    assertThat(postedBody).isEqualTo(requestObject);
}