use of com.apollographql.apollo.api.internal.UnmodifiableMapBuilder in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithNestedObjectAndVariables.
@Test
public void testFieldWithNestedObjectAndVariables() {
// noinspection unchecked
Map<String, Object> arguments = new UnmodifiableMapBuilder<String, Object>(1).put("episode", "JEDI").put("nested", new UnmodifiableMapBuilder<String, Object>(2).put("foo", new UnmodifiableMapBuilder<String, Object>(2).put("kind", "Variable").put("variableName", "stars").build()).put("bar", "2").build()).build();
ResponseField field = createResponseField("hero", "hero", arguments);
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("stars", 1);
return map;
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"episode\":\"JEDI\",\"nested\":{\"bar\":\"2\",\"foo\":1}})");
}
use of com.apollographql.apollo.api.internal.UnmodifiableMapBuilder in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithArgumentAndAlias.
@Test
public void testFieldWithArgumentAndAlias() {
// noinspection unchecked
Map<String, Object> arguments = new UnmodifiableMapBuilder<String, Object>(1).put("episode", "JEDI").build();
ResponseField field = createResponseField("r2", "hero", arguments);
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"episode\":\"JEDI\"})");
}
use of com.apollographql.apollo.api.internal.UnmodifiableMapBuilder in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithVariableArgument.
@Test
public void testFieldWithVariableArgument() {
// noinspection unchecked
UnmodifiableMapBuilder<String, Object> argument = new UnmodifiableMapBuilder<String, Object>(1).put("episode", new UnmodifiableMapBuilder<String, Object>(2).put("kind", "Variable").put("variableName", "episode").build());
ResponseField field = createResponseField("hero", "hero", argument.build());
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("episode", Episode.JEDI);
return map;
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"episode\":\"JEDI\"})");
}
use of com.apollographql.apollo.api.internal.UnmodifiableMapBuilder in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithVariableArgumentNull.
@Test
public void testFieldWithVariableArgumentNull() {
// noinspection unchecked
UnmodifiableMapBuilder<String, Object> argument = new UnmodifiableMapBuilder<String, Object>(1).put("episode", new UnmodifiableMapBuilder<String, Object>(2).put("kind", "Variable").put("variableName", "episode").build());
ResponseField field = createResponseField("hero", "hero", argument.build());
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("episode", null);
return map;
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"episode\":null})");
}
use of com.apollographql.apollo.api.internal.UnmodifiableMapBuilder in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithArgument.
@Test
public void testFieldWithArgument() {
// noinspection unchecked
Map<String, Object> arguments = new UnmodifiableMapBuilder<String, Object>(1).put("episode", "JEDI").build();
ResponseField field = createResponseField("hero", "hero", arguments);
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"episode\":\"JEDI\"})");
}
Aggregations