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));
}
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"));
}
Aggregations