Search in sources :

Example 21 with AllPlanetsQuery

use of com.apollographql.apollo.integration.httpcache.AllPlanetsQuery in project apollo-android by apollographql.

the class ResponseNormalizationTest method list_of_objects_with_null_object.

@Test
public void list_of_objects_with_null_object() throws Exception {
    assertHasNoErrors("AllPlanetsListOfObjectWithNullObject.json", new AllPlanetsQuery());
    String fieldKey = "allPlanets({\"first\":\"300.0\"})";
    Record record = normalizedCache.loadRecord(fieldKey + ".planets.0", CacheHeaders.NONE);
    assertThat(record.field("filmConnection")).isNull();
    record = normalizedCache.loadRecord(fieldKey + ".planets.0.filmConnection", CacheHeaders.NONE);
    assertThat(record).isNull();
    record = normalizedCache.loadRecord(fieldKey + ".planets.1.filmConnection", CacheHeaders.NONE);
    assertThat(record).isNotNull();
}
Also used : AllPlanetsQuery(com.apollographql.apollo.integration.httpcache.AllPlanetsQuery) Record(com.apollographql.apollo.cache.normalized.Record) Test(org.junit.Test)

Aggregations

AllPlanetsQuery (com.apollographql.apollo.integration.httpcache.AllPlanetsQuery)21 Test (org.junit.Test)21 Response (com.apollographql.apollo.api.Response)12 MockResponse (okhttp3.mockwebserver.MockResponse)12 ApolloException (com.apollographql.apollo.exception.ApolloException)11 IOException (java.io.IOException)11 ApolloHttpException (com.apollographql.apollo.exception.ApolloHttpException)10 ParseException (java.text.ParseException)10 Utils.assertResponse (com.apollographql.apollo.Utils.assertResponse)2 Utils.enqueueAndAssertResponse (com.apollographql.apollo.Utils.enqueueAndAssertResponse)2 Utils.mockResponse (com.apollographql.apollo.Utils.mockResponse)2 Buffer (okio.Buffer)2 Utils.cacheAndAssertCachedResponse (com.apollographql.apollo.Utils.cacheAndAssertCachedResponse)1 DiskLruHttpCacheStore (com.apollographql.apollo.cache.http.DiskLruHttpCacheStore)1 Record (com.apollographql.apollo.cache.normalized.Record)1 JsonWriter (com.apollographql.apollo.internal.json.JsonWriter)1 OperationJsonWriter (com.apollographql.apollo.response.OperationJsonWriter)1 ScalarTypeAdapters (com.apollographql.apollo.response.ScalarTypeAdapters)1 File (java.io.File)1 Dispatcher (okhttp3.Dispatcher)1