use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTFunctionCallStringIT method testASTConcatParse.
@Test
public void testASTConcatParse() {
Expression exp = ExpressionFactory.exp("concat('abc', 'def')");
assertEquals("abcdef", exp.evaluate(new Object()));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTFunctionCallStringIT method testASTTrimParse.
@Test
public void testASTTrimParse() {
Expression exp = ExpressionFactory.exp("trim(' abc ')");
assertEquals("abc", exp.evaluate(new Object()));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTGreaterOrEqualTest method testEvaluate_Null.
@Test
public void testEvaluate_Null() {
Expression gtNull = new ASTGreaterOrEqual(new ASTObjPath("estimatedPrice"), null);
Expression gtNotNull = new ASTGreaterOrEqual(new ASTObjPath("estimatedPrice"), new BigDecimal(10000d));
Painting noMatch = new Painting();
assertFalse(gtNull.match(noMatch));
assertFalse(gtNotNull.match(noMatch));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTInTest method testEvaluate_Null.
@Test
public void testEvaluate_Null() {
Expression in = new ASTIn(new ASTObjPath("estimatedPrice"), new ASTList(new Object[] { new BigDecimal("10"), new BigDecimal("20") }));
Expression notIn = new ASTNotIn(new ASTObjPath("estimatedPrice"), new ASTList(new Object[] { new BigDecimal("10"), new BigDecimal("20") }));
Painting noMatch = new Painting();
assertFalse(in.match(noMatch));
assertFalse(notIn.match(noMatch));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLessTest method testEvaluate.
@Test
public void testEvaluate() {
Expression e = new ASTLess(new ASTObjPath("estimatedPrice"), new BigDecimal(10000d));
Painting noMatch = new Painting();
noMatch.setEstimatedPrice(new BigDecimal(10001));
assertFalse("Failed: " + e, e.match(noMatch));
Painting noMatch1 = new Painting();
noMatch1.setEstimatedPrice(new BigDecimal(10000));
assertFalse("Failed: " + e, e.match(noMatch1));
Painting match = new Painting();
match.setEstimatedPrice(new BigDecimal(9999));
assertTrue("Failed: " + e, e.match(match));
}
Aggregations