JsonSerializerImpl implements JsonSerializer { @Override public String toJson(Payload payload) { if (payload.json != null) { return payload.json; } StringBuilder builder = new StringBuilder(); serializeValue(builder, payload, 0); return builder.toString(); } JsonSerializerImpl();  JsonSerializerImpl(boolean prettyPrint); @Override String toJson(Payload payload); @Override Result resultFrom(String response);  }
@Test public void shouldSerializeJsonPayload() { String json = "{\"foo\":\"bar\"}"; Payload payload = new Payload(json); JsonSerializerImpl sut = new JsonSerializerImpl(); assertThat(sut.toJson(payload), is(json)); }