use of com.google.template.soy.data.internal.SoyMapImpl in project closure-templates by google.
the class MapToLegacyObjectMapFunctionTest method computeForJava.
@Test
public void computeForJava() {
SoyMapImpl map = SoyMapImpl.forProviderMap(ImmutableMap.of(IntegerData.forValue(42), CONVERTER.convert("y"), StringData.forValue("z"), SoyValueConverterUtility.newDict("xx", 2)));
SoyDict expectedMap = SoyValueConverterUtility.newDict("42", "y", "z", SoyValueConverterUtility.newDict("xx", 2));
SoyDict convertedMap = (SoyDict) MAP_TO_LEGACY_OBJECT_MAP.computeForJava(ImmutableList.of(map));
// Keys are coerced to strings in the legacy object map.
assertThat(expectedMap.getItem(StringData.forValue("42"))).isEqualTo(convertedMap.getItem(StringData.forValue("42")));
}
use of com.google.template.soy.data.internal.SoyMapImpl in project closure-templates by google.
the class LegacyObjectMapToMapFunctionTest method computeForJava.
@Test
public void computeForJava() {
SoyLegacyObjectMap legacyObjectMap = SoyValueConverterUtility.newDict("x", "y", "z", SoyValueConverterUtility.newDict("xx", 2));
SoyMapImpl map = SoyMapImpl.forProviderMap(ImmutableMap.of(StringData.forValue("x"), CONVERTER.convert("y"), StringData.forValue("z"), SoyValueConverterUtility.newDict("xx", 2)));
SoyMapImpl convertedMap = (SoyMapImpl) LEGACY_OBJECT_MAP_TO_MAP.computeForJava(ImmutableList.of(legacyObjectMap));
assertThat(map.get(StringData.forValue("x"))).isEqualTo(convertedMap.get(StringData.forValue("x")));
}
Aggregations