use of com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDForParentOnlyQuery in project apollo-android by apollographql.
the class ResponseNormalizationTest method testHeroAndFriendsNamesWithIDForParentOnly.
@Test
public void testHeroAndFriendsNamesWithIDForParentOnly() throws Exception {
assertHasNoErrors("HeroAndFriendsNameWithIdsParentOnlyResponse.json", new HeroAndFriendsNamesWithIDForParentOnlyQuery(Input.fromNullable(JEDI)));
Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI);
assertThat(heroReference).isEqualTo(new CacheReference("2001"));
final Record heroRecord = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
assertThat(heroRecord.field("name")).isEqualTo("R2-D2");
assertThat(heroRecord.field("friends")).isEqualTo(Arrays.asList(new CacheReference("2001.friends.0"), new CacheReference("2001.friends.1"), new CacheReference("2001.friends.2")));
final Record luke = normalizedCache.loadRecord("2001.friends.0", CacheHeaders.NONE);
assertThat(luke.field("name")).isEqualTo("Luke Skywalker");
}
Aggregations