use of com.apollographql.apollo.integration.normalizer.StarshipByIdQuery in project apollo-android by apollographql.
the class ResponseWriteTestCase method listOfList.
@Test
public void listOfList() throws Exception {
StarshipByIdQuery query = new StarshipByIdQuery("Starship1");
enqueueAndAssertResponse(server, "StarshipByIdResponse.json", apolloClient.query(query), new Predicate<Response<StarshipByIdQuery.Data>>() {
@Override
public boolean test(Response<StarshipByIdQuery.Data> response) throws Exception {
assertThat(response.data().starship().__typename()).isEqualTo("Starship");
assertThat(response.data().starship().name()).isEqualTo("SuperRocket");
assertThat(response.data().starship().coordinates()).hasSize(3);
assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), asList(500d, 600d));
return true;
}
});
StarshipByIdQuery.Starship starship = new StarshipByIdQuery.Starship("Starship", "Starship1", "SuperRocket", asList(asList(900d, 800d), asList(700d, 600d)));
apolloClient.apolloStore().write(query, new StarshipByIdQuery.Data(starship)).execute();
assertCachedQueryResponse(query, new Predicate<Response<StarshipByIdQuery.Data>>() {
@Override
public boolean test(Response<StarshipByIdQuery.Data> response) throws Exception {
assertThat(response.data().starship().__typename()).isEqualTo("Starship");
assertThat(response.data().starship().name()).isEqualTo("SuperRocket");
assertThat(response.data().starship().coordinates()).hasSize(2);
assertThat(response.data().starship().coordinates()).containsExactly(asList(900d, 800d), asList(700d, 600d));
return true;
}
});
}
use of com.apollographql.apollo.integration.normalizer.StarshipByIdQuery in project apollo-android by apollographql.
the class NormalizedCacheTestCase method listOfList.
@Test
public void listOfList() throws Exception {
enqueueAndAssertResponse(server, "StarshipByIdResponse.json", apolloClient.query(new StarshipByIdQuery("Starship1")), new Predicate<Response<StarshipByIdQuery.Data>>() {
@Override
public boolean test(Response<StarshipByIdQuery.Data> response) throws Exception {
assertThat(response.data().starship().__typename()).isEqualTo("Starship");
assertThat(response.data().starship().name()).isEqualTo("SuperRocket");
assertThat(response.data().starship().coordinates()).hasSize(3);
assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), asList(500d, 600d));
return true;
}
});
assertResponse(apolloClient.query(new StarshipByIdQuery("Starship1")).responseFetcher(CACHE_ONLY), new Predicate<Response<StarshipByIdQuery.Data>>() {
@Override
public boolean test(Response<StarshipByIdQuery.Data> response) throws Exception {
assertThat(response.data().starship().__typename()).isEqualTo("Starship");
assertThat(response.data().starship().name()).isEqualTo("SuperRocket");
assertThat(response.data().starship().coordinates()).hasSize(3);
assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), asList(500d, 600d));
return true;
}
});
}
Aggregations