### Question:
JSONFormat extends Format<JsonObject> { public static JSONFormat json() { return new JSONFormat(); } private  JSONFormat(); static JSONFormat json(); static Result<JsonObject, Exception> json(final Reader reader); static W json(final W writer, final JsonObject object); static Supplier<JsonObject> context(); static Function<String, String> aliaser(final JsonObject context); static Function<String, String> resolver(final JsonObject context); @Override Result<JsonObject, Failure> get(final Message<?> message); @Override M set(final M message, final JsonObject value); static final String MIME; static final Pattern MIMEPattern; static final String id; static final String value; static final String type; static final String language; }### Answer:
@Test void testRetrieveJSON() { final Request request=new Request() .header("content-type", JSONFormat.MIME) .body(reader(), () -> new StringReader(TestJSON.toString())); assertThat(request.body(json()).value()) .isPresent() .contains(TestJSON); }
@Test void testRetrieveJSONChecksContentType() { final Request request=new Request() .body(reader(), () -> new StringReader(TestJSON.toString())); assertThat(request.body(json()).value()) .isNotPresent(); }
@Test void testConfigureJSON() { final Request request=new Request().body(json(), TestJSON); assertThat (request .body(writer()) .value(client -> { try ( final StringWriter writer=new StringWriter() ) { client.accept(() -> writer); return writer.toString(); } catch ( final IOException e ) { throw new UncheckedIOException(e); } }) .value(test -> Json.createReader(new StringReader(test)).readObject()) .value() ) .isPresent() .contains(TestJSON); }
@Test void testConfigureJSONSetsContentType() { final Request request=new Request().body(json(), TestJSON); assertThat(request.header("content-type")) .isPresent() .contains(JSONFormat.MIME); }