Search in sources :

Example 1 with CharacterDetailsQuery

use of com.apollographql.apollo.integration.normalizer.CharacterDetailsQuery in project apollo-android by apollographql.

the class NormalizedCacheTestCase method masterDetailFailIncomplete.

@Test
public void masterDetailFailIncomplete() throws Exception {
    enqueueAndAssertResponse(server, "HeroAndFriendsNameWithIdsResponse.json", apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))).responseFetcher(NETWORK_ONLY), new Predicate<Response<HeroAndFriendsNamesWithIDsQuery.Data>>() {

        @Override
        public boolean test(Response<HeroAndFriendsNamesWithIDsQuery.Data> response) throws Exception {
            return !response.hasErrors();
        }
    });
    assertResponse(apolloClient.query(new CharacterDetailsQuery("1002")).responseFetcher(CACHE_ONLY), new Predicate<Response<CharacterDetailsQuery.Data>>() {

        @Override
        public boolean test(Response<CharacterDetailsQuery.Data> response) throws Exception {
            assertThat(response.data()).isNull();
            return true;
        }
    });
}
Also used : Utils.mockResponse(com.apollographql.apollo.Utils.mockResponse) Utils.enqueueAndAssertResponse(com.apollographql.apollo.Utils.enqueueAndAssertResponse) Utils.cacheAndAssertCachedResponse(com.apollographql.apollo.Utils.cacheAndAssertCachedResponse) Utils.assertResponse(com.apollographql.apollo.Utils.assertResponse) Response(com.apollographql.apollo.api.Response) CharacterDetailsQuery(com.apollographql.apollo.integration.normalizer.CharacterDetailsQuery) HeroAndFriendsNamesWithIDsQuery(com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery) Test(org.junit.Test)

Aggregations

Utils.assertResponse (com.apollographql.apollo.Utils.assertResponse)1 Utils.cacheAndAssertCachedResponse (com.apollographql.apollo.Utils.cacheAndAssertCachedResponse)1 Utils.enqueueAndAssertResponse (com.apollographql.apollo.Utils.enqueueAndAssertResponse)1 Utils.mockResponse (com.apollographql.apollo.Utils.mockResponse)1 Response (com.apollographql.apollo.api.Response)1 CharacterDetailsQuery (com.apollographql.apollo.integration.normalizer.CharacterDetailsQuery)1 HeroAndFriendsNamesWithIDsQuery (com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery)1 Test (org.junit.Test)1