use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_IllegalOperator.
@Test(expected = ExpressionRuntimeException.class)
public void testPredicate_IllegalOperator() {
SeqPredicateFunction fun = new SeqPredicateFunction("and", OperatorType.AND, AviatorRuntimeJavaType.valueOf("hello"));
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_eq.
@Test
public void testPredicate_eq() {
SeqPredicateFunction fun = new SeqPredicateFunction("eq", OperatorType.EQ, AviatorRuntimeJavaType.valueOf("hello"));
AviatorObject result = fun.call(null, AviatorRuntimeJavaType.valueOf("hello"));
assertTrue(result.booleanValue(null));
result = fun.call(null, AviatorRuntimeJavaType.valueOf("he1lo"));
assertFalse(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqPredicateFunctionUnitTest method testPredicate_property.
@Test
public void testPredicate_property() {
Map<String, String> data = new HashMap<>();
for (int i = 0; i < 5; i++) {
data.put("key" + i, "value" + i);
}
SeqPredicateFunction predicate = new SeqPredicateFunction("eq_temp_1", OperatorType.EQ, new AviatorString("value1"), new AviatorString("key1"));
AviatorObject result = predicate.call(null, AviatorRuntimeJavaType.valueOf(data));
assertTrue(result.booleanValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqReduceFunctionUnitTest method testReduce_String.
@Test
public void testReduce_String() {
SeqReduceFunction fun = new SeqReduceFunction();
AviatorObject result = fun.call(AviatorEvaluator.FUNC_MAP, AviatorRuntimeJavaType.valueOf("hello"), new AviatorJavaType("+"), AviatorRuntimeJavaType.valueOf(0));
assertEquals("0hello", result.getValue(null));
}
use of com.googlecode.aviator.runtime.type.AviatorObject in project aviatorscript by killme2008.
the class SeqReduceFunctionUnitTest method testReduce_Collection.
@Test
public void testReduce_Collection() {
LinkedHashSet<Integer> a = new LinkedHashSet<Integer>();
for (int i = 0; i < 10; i++) {
a.add(i);
}
SeqReduceFunction fun = new SeqReduceFunction();
AviatorObject result = fun.call(this.env, AviatorRuntimeJavaType.valueOf(a), new AviatorJavaType("+"), AviatorRuntimeJavaType.valueOf(0));
assertNotNull(result);
assertEquals(45, result.getValue(null));
}
Aggregations