Response { public Optional<Object> decodeJson() { if (!success()) { return Optional.empty(); } else { return Optional.ofNullable(Json.fromJson(text)); } } Response(int status, String text, Map<String, List<String>> headers); int getStatus(); String getText(); Map<String, List<String>> getHeaders(); boolean success(); Optional<Object> decodeJson(); Stream<Object> decodeJsonArray();  }
@Test void decodeJson() { assertNotEquals(Optional.empty(), instance.decodeJson()); final Response fail = new Response(400, "{}", new HashMap<>()); assertEquals(Optional.empty(), fail.decodeJson()); }