Search in sources :

Example 1 with HeroAppearsInQuery

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

the class ResponseNormalizationTest method testHeroAppearsInQuery.

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

Aggregations

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