### Question:
JsonAdapter { @CheckReturnValue public abstract @Nullable T fromJson(JsonReader reader) throws IOException;  @CheckReturnValue abstract @Nullable T fromJson(JsonReader reader); @CheckReturnValue final @Nullable T fromJson(BufferedSource source); @CheckReturnValue final @Nullable T fromJson(String string); abstract void toJson(JsonWriter writer, @Nullable T value); final void toJson(BufferedSink sink, @Nullable T value); @CheckReturnValue final String toJson(@Nullable T value); @CheckReturnValue final @Nullable Object toJsonValue(@Nullable T value); @CheckReturnValue final @Nullable T fromJsonValue(@Nullable Object value); @CheckReturnValue final JsonAdapter<T> serializeNulls(); @CheckReturnValue final JsonAdapter<T> nullSafe(); @CheckReturnValue final JsonAdapter<T> nonNull(); @CheckReturnValue final JsonAdapter<T> lenient(); @CheckReturnValue final JsonAdapter<T> failOnUnknown(); @CheckReturnValue JsonAdapter<T> indent(final String indent);  }### Answer:
@Test public void stringDocumentMustBeFullyConsumed() throws IOException { JsonAdapter<String> brokenAdapter = new JsonAdapter<String>() { @Override public String fromJson(JsonReader reader) throws IOException { return "Forgot to call reader.nextString()."; } @Override public void toJson(JsonWriter writer, @Nullable String value) throws IOException { throw new AssertionError(); } }; try { brokenAdapter.fromJson("\"value\""); fail(); } catch (JsonDataException e) { assertThat(e).hasMessageThat().isEqualTo("JSON document was not fully consumed."); } }
@Test public void adapterFromJsonStringPeeksAtEnd() throws IOException { JsonAdapter<Boolean> adapter = new JsonAdapter<Boolean>() { @Override public Boolean fromJson(JsonReader reader) throws IOException { return reader.nextBoolean(); } @Override public void toJson(JsonWriter writer, @Nullable Boolean value) throws IOException { throw new AssertionError(); } }; try { adapter.fromJson("true true"); fail(); } catch (JsonEncodingException e) { assertThat(e) .hasMessageThat() .isEqualTo("Use JsonReader.setLenient(true) to accept malformed JSON at path $"); } }