use of com.apollographql.apollo.response.OperationJsonWriter in project apollo-android by apollographql.
the class IntegrationTest method operationJsonWriter.
@Test
public void operationJsonWriter() throws Exception {
String json = Utils.readFileToString(getClass(), "/OperationJsonWriter.json");
AllPlanetsQuery query = new AllPlanetsQuery();
Response<AllPlanetsQuery.Data> response = new OperationResponseParser<>(query, query.responseFieldMapper(), new ScalarTypeAdapters(Collections.EMPTY_MAP)).parse(new Buffer().writeUtf8(json));
Buffer buffer = new Buffer();
OperationJsonWriter writer = new OperationJsonWriter(response.data(), new ScalarTypeAdapters(Collections.EMPTY_MAP));
JsonWriter jsonWriter = JsonWriter.of(buffer);
jsonWriter.setIndent(" ");
writer.write(jsonWriter);
assertThat(buffer.readUtf8()).isEqualTo(json);
}
Aggregations