use of com.apollographql.apollo.cache.normalized.Record in project apollo-android by apollographql.
the class ResponseNormalizationTest method testHeroNameWithVariable.
@Test
public void testHeroNameWithVariable() throws Exception {
assertHasNoErrors("EpisodeHeroNameResponse.json", new EpisodeHeroNameQuery(Input.fromNullable(JEDI)));
Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
CacheReference reference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI);
assertThat(reference).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI));
final Record heroRecord = normalizedCache.loadRecord(reference.key(), CacheHeaders.NONE);
assertThat(heroRecord.field("name")).isEqualTo("R2-D2");
}
use of com.apollographql.apollo.cache.normalized.Record in project apollo-android by apollographql.
the class ResponseNormalizationTest method testSameHeroTwiceQuery.
@Test
public void testSameHeroTwiceQuery() throws Exception {
assertHasNoErrors("SameHeroTwiceResponse.json", new SameHeroTwiceQuery());
Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
CacheReference heroReference = (CacheReference) record.field("hero");
final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE);
assertThat(hero.field("name")).isEqualTo("R2-D2");
assertThat(hero.field("appearsIn")).isEqualTo(Arrays.asList("NEWHOPE", "EMPIRE", "JEDI"));
}
use of com.apollographql.apollo.cache.normalized.Record 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"));
}
use of com.apollographql.apollo.cache.normalized.Record 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"));
}
use of com.apollographql.apollo.cache.normalized.Record in project apollo-android by apollographql.
the class ResponseNormalizationTest method testHeroName.
@Test
public void testHeroName() throws Exception {
assertHasNoErrors("HeroNameResponse.json", new HeroNameQuery());
Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE);
CacheReference reference = (CacheReference) record.field("hero");
assertThat(reference).isEqualTo(new CacheReference("hero"));
final Record heroRecord = normalizedCache.loadRecord(reference.key(), CacheHeaders.NONE);
assertThat(heroRecord.field("name")).isEqualTo("R2-D2");
}
Aggregations