use of com.apollographql.apollo.api.ResponseField in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithNoArguments.
@Test
public void testFieldWithNoArguments() {
ResponseField field = ResponseField.forString("hero", "hero", null, false, Collections.<ResponseField.Condition>emptyList());
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero");
}
use of com.apollographql.apollo.api.ResponseField in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithMultipleArgumentsOrderIndependent.
@Test
public void testFieldWithMultipleArgumentsOrderIndependent() {
// noinspection unchecked
Map<String, Object> arguments = new UnmodifiableMapBuilder<String, Object>(1).put("episode", "JEDI").put("color", "blue").build();
ResponseField field = createResponseField("hero", "hero", arguments);
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
// noinspection unchecked
Map<String, Object> fieldTwoArguments = new UnmodifiableMapBuilder<String, Object>(1).put("color", "blue").put("episode", "JEDI").build();
ResponseField fieldTwo = createResponseField("hero", "hero", fieldTwoArguments);
assertThat(fieldTwo.cacheKey(variables)).isEqualTo(field.cacheKey(variables));
}
use of com.apollographql.apollo.api.ResponseField in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithNoArgumentsWithAlias.
@Test
public void testFieldWithNoArgumentsWithAlias() {
ResponseField field = ResponseField.forString("r2", "hero", null, false, Collections.<ResponseField.Condition>emptyList());
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero");
}
use of com.apollographql.apollo.api.ResponseField 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.ResponseField in project apollo-android by apollographql.
the class CacheKeyForFieldTest method testFieldWithMultipleArgument.
@Test
public void testFieldWithMultipleArgument() {
// noinspection unchecked
Map<String, Object> build = new UnmodifiableMapBuilder<String, Object>(1).put("episode", "JEDI").put("color", "blue").build();
ResponseField field = createResponseField("hero", "hero", build);
Operation.Variables variables = new Operation.Variables() {
@Nonnull
@Override
public Map<String, Object> valueMap() {
return super.valueMap();
}
};
assertThat(field.cacheKey(variables)).isEqualTo("hero({\"color\":\"blue\",\"episode\":\"JEDI\"})");
}
Aggregations