Search in sources :

Example 1 with HeroTypeDependentAliasedFieldQuery

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

the class ResponseNormalizationTest method testHeroParentTypeDependentAliasedFieldQueryHuman.

@Test
public void testHeroParentTypeDependentAliasedFieldQueryHuman() throws Exception {
    assertHasNoErrors("HeroTypeDependentAliasedFieldResponseHuman.json", new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(EMPIRE)));
    Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
    CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_EMPIRE);
    final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
    assertThat(hero.field("homePlanet")).isEqualTo("Tatooine");
    assertThat(hero.field("__typename")).isEqualTo("Human");
}
Also used : HeroTypeDependentAliasedFieldQuery(com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery) Record(com.apollographql.apollo.cache.normalized.Record) CacheReference(com.apollographql.apollo.cache.normalized.CacheReference) Test(org.junit.Test)

Example 2 with HeroTypeDependentAliasedFieldQuery

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

the class ResponseNormalizationTest method testHeroTypeDependentAliasedFieldQueryDroid.

@Test
public void testHeroTypeDependentAliasedFieldQueryDroid() throws Exception {
    assertHasNoErrors("HeroTypeDependentAliasedFieldResponse.json", new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(JEDI)));
    Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
    CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI);
    final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
    assertThat(hero.field("primaryFunction")).isEqualTo("Astromech");
    assertThat(hero.field("__typename")).isEqualTo("Droid");
}
Also used : HeroTypeDependentAliasedFieldQuery(com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery) Record(com.apollographql.apollo.cache.normalized.Record) CacheReference(com.apollographql.apollo.cache.normalized.CacheReference) Test(org.junit.Test)

Example 3 with HeroTypeDependentAliasedFieldQuery

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

the class ResponseNormalizationTest method testHeroTypeDependentAliasedFieldQueryHuman.

@Test
public void testHeroTypeDependentAliasedFieldQueryHuman() throws Exception {
    assertHasNoErrors("HeroTypeDependentAliasedFieldResponseHuman.json", new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(EMPIRE)));
    Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
    CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_EMPIRE);
    final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
    assertThat(hero.field("homePlanet")).isEqualTo("Tatooine");
    assertThat(hero.field("__typename")).isEqualTo("Human");
}
Also used : HeroTypeDependentAliasedFieldQuery(com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery) 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)3 Record (com.apollographql.apollo.cache.normalized.Record)3 HeroTypeDependentAliasedFieldQuery (com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery)3 Test (org.junit.Test)3