Search in sources :

Example 1 with HeroParentTypeDependentFieldQuery

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

the class ResponseNormalizationTest method testHeroParentTypeDependentFieldHuman.

@Test
public void testHeroParentTypeDependentFieldHuman() throws Exception {
    assertHasNoErrors("HeroParentTypeDependentFieldHumanResponse.json", new HeroParentTypeDependentFieldQuery(Input.fromNullable(EMPIRE)));
    Record lukeRecord = normalizedCache.loadRecord(TEST_FIELD_KEY_EMPIRE + ".friends.0", CacheHeaders.NONE);
    assertThat(lukeRecord.field("name")).isEqualTo("Han Solo");
    assertThat(lukeRecord.field("height({\"unit\":\"FOOT\"})")).isEqualTo(BigDecimal.valueOf(5.905512));
}
Also used : HeroParentTypeDependentFieldQuery(com.apollographql.apollo.integration.normalizer.HeroParentTypeDependentFieldQuery) Record(com.apollographql.apollo.cache.normalized.Record) Test(org.junit.Test)

Example 2 with HeroParentTypeDependentFieldQuery

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

the class ResponseNormalizationTest method testHeroParentTypeDependentFieldDroid.

@Test
public void testHeroParentTypeDependentFieldDroid() throws Exception {
    assertHasNoErrors("HeroParentTypeDependentFieldDroidResponse.json", new HeroParentTypeDependentFieldQuery(Input.fromNullable(JEDI)));
    Record lukeRecord = normalizedCache.loadRecord(TEST_FIELD_KEY_JEDI + ".friends.0", CacheHeaders.NONE);
    assertThat(lukeRecord.field("name")).isEqualTo("Luke Skywalker");
    assertThat(lukeRecord.field("height({\"unit\":\"METER\"})")).isEqualTo(BigDecimal.valueOf(1.72));
    final List<Object> friends = (List<Object>) normalizedCache.loadRecord(TEST_FIELD_KEY_JEDI, CacheHeaders.NONE).field("friends");
    assertThat(friends.get(0)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.0"));
    assertThat(friends.get(1)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.1"));
    assertThat(friends.get(2)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.2"));
}
Also used : HeroParentTypeDependentFieldQuery(com.apollographql.apollo.integration.normalizer.HeroParentTypeDependentFieldQuery) Record(com.apollographql.apollo.cache.normalized.Record) List(java.util.List) CacheReference(com.apollographql.apollo.cache.normalized.CacheReference) Test(org.junit.Test)

Aggregations

Record (com.apollographql.apollo.cache.normalized.Record)2 HeroParentTypeDependentFieldQuery (com.apollographql.apollo.integration.normalizer.HeroParentTypeDependentFieldQuery)2 Test (org.junit.Test)2 CacheReference (com.apollographql.apollo.cache.normalized.CacheReference)1 List (java.util.List)1