use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrIndexOfFunctionTest method testComputeForJava_containsSanitizedContent.
@Test
public void testComputeForJava_containsSanitizedContent() {
StrIndexOfFunction strIndexOf = new StrIndexOfFunction();
SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
SoyValue arg1 = ordainAsSafe("bar", ContentKind.TEXT);
assertThat(strIndexOf.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(IntegerData.forValue(3));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrSubFunctionTest method testComputeForJava_noEndIndex_SanitizedContent.
@Test
public void testComputeForJava_noEndIndex_SanitizedContent() {
StrSubFunction strSub = new StrSubFunction();
SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
SoyValue arg1 = IntegerData.forValue(2);
assertThat(strSub.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(StringData.forValue("obarfoo"));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class KeysFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
KeysFunction keysFunction = new KeysFunction();
SoyValue map = SoyValueConverterUtility.newDict("boo", "bar", "foo", 2, "goo", SoyValueConverterUtility.newDict("moo", 4));
SoyValue result = keysFunction.computeForJava(ImmutableList.of(map));
assertThat(result).isInstanceOf(SoyList.class);
SoyList resultAsList = (SoyList) result;
assertThat(resultAsList.length()).isEqualTo(3);
Set<String> resultItems = Sets.newHashSet();
for (SoyValueProvider itemProvider : resultAsList.asJavaList()) {
resultItems.add(itemProvider.resolve().stringValue());
}
assertThat(resultItems).containsExactly("boo", "foo", "goo");
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class MaxFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
MaxFunction maxFunction = new MaxFunction();
SoyValue float0 = FloatData.forValue(7.5);
SoyValue float1 = FloatData.forValue(7.777);
assertThat(maxFunction.computeForJava(ImmutableList.of(float0, float1))).isEqualTo(FloatData.forValue(7.777));
SoyValue integer0 = IntegerData.forValue(-7);
SoyValue integer1 = IntegerData.forValue(-8);
assertThat(maxFunction.computeForJava(ImmutableList.of(integer0, integer1))).isEqualTo(IntegerData.forValue(-7));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrContainsFunctionTest method testComputeForJava_containsSanitizedContent.
@Test
public void testComputeForJava_containsSanitizedContent() {
StrContainsFunction strContains = new StrContainsFunction();
SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
SoyValue arg1 = ordainAsSafe("bar", ContentKind.TEXT);
assertThat(strContains.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(BooleanData.TRUE);
}
Aggregations