MoshiHelper { public static void dump(BufferedSource source, JsonWriter writer) throws IOException { dump(JsonReader.of(source), writer); }  static void dump(BufferedSource source, JsonWriter writer); static void dump(JsonReader reader, BufferedSink sink); static void dump(JsonReader reader, JsonWriter writer); static String nextNullableString(JsonReader reader); static T nextNullableObject(JsonReader reader, JsonAdapter<T> adapter); static void writeNullable(JsonWriter writer, JsonAdapter<T> valueAdapter, String name, T value); static void writeNullable(JsonWriter writer, JsonAdapter<T> valueAdapter, String name, T value, boolean enforced); static void writeNullableValue(JsonWriter writer, JsonAdapter<T> adapter, T value, boolean enforced); static void writeNull(JsonWriter writer, boolean enforced);  }
@Test public void equality() throws Exception { String json = TestUtil.fromResource("/sample.json"); Buffer a = new Buffer(); Buffer b = new Buffer(); a.writeString(json, Charset.forName("UTF-8")); MoshiHelper.dump(JsonReader.of(a), b); assertEquals(b.readString(Charset.forName("UTF-8")), json); }
@Test(expected = EOFException.class) public void eof_exception() throws Exception { Buffer a = new Buffer(); Buffer b = new Buffer(); MoshiHelper.dump(JsonReader.of(a), b); }