Search in sources :

Example 1 with SameHeroTwiceQuery

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

the class ResponseNormalizationTest method testSameHeroTwiceQuery.

@Test
public void testSameHeroTwiceQuery() throws Exception {
    assertHasNoErrors("SameHeroTwiceResponse.json", new SameHeroTwiceQuery());
    Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
    CacheReference heroReference = (CacheReference) record.field("hero");
    final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
    assertThat(hero.field("name")).isEqualTo("R2-D2");
    assertThat(hero.field("appearsIn")).isEqualTo(Arrays.asList("NEWHOPE", "EMPIRE", "JEDI"));
}
Also used : Record(com.apollographql.apollo.cache.normalized.Record) CacheReference(com.apollographql.apollo.cache.normalized.CacheReference) SameHeroTwiceQuery(com.apollographql.apollo.integration.normalizer.SameHeroTwiceQuery) Test(org.junit.Test)

Aggregations

CacheReference (com.apollographql.apollo.cache.normalized.CacheReference)1 Record (com.apollographql.apollo.cache.normalized.Record)1 SameHeroTwiceQuery (com.apollographql.apollo.integration.normalizer.SameHeroTwiceQuery)1 Test (org.junit.Test)1