Search in sources :

Example 76 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallMathIT method testASTModParse.

@Test
public void testASTModParse() {
    Expression exp = ExpressionFactory.exp("mod(11,2)");
    assertEquals(1.0, exp.evaluate(new Object()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 77 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallMathIT method testASTAbsParse.

@Test
public void testASTAbsParse() {
    Expression exp = ExpressionFactory.exp("abs(-3)");
    assertEquals(3.0, exp.evaluate(new Object()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 78 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallStringIT method testASTUpperParse.

@Test
public void testASTUpperParse() {
    Expression exp = ExpressionFactory.exp("upper('aBc')");
    assertEquals("ABC", exp.evaluate(new Object()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 79 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallStringIT method testASTLowerParse.

@Test
public void testASTLowerParse() {
    Expression exp = ExpressionFactory.exp("lower('AbC')");
    assertEquals("abc", exp.evaluate(new Object()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 80 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class ASTFunctionCallStringIT method testComplexParse.

@Test
public void testComplexParse() {
    Expression exp = ExpressionFactory.exp("locate(upper('Bc'), upper('aBc')) = length(substring(trim(lower(concat('   abc', 'def   '))), 3, 2))");
    assertEquals(true, exp.evaluate(new Object()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Aggregations

Expression (org.apache.cayenne.exp.Expression)298 Test (org.junit.Test)265 Artist (org.apache.cayenne.testdo.testmap.Artist)69 SelectQuery (org.apache.cayenne.query.SelectQuery)47 Painting (org.apache.cayenne.testdo.testmap.Painting)29 BigDecimal (java.math.BigDecimal)23 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)17 DateTestEntity (org.apache.cayenne.testdo.date_time.DateTestEntity)16 ObjEntity (org.apache.cayenne.map.ObjEntity)13 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)12 DbEntity (org.apache.cayenne.map.DbEntity)10 List (java.util.List)9 HashMap (java.util.HashMap)8 DataRow (org.apache.cayenne.DataRow)8 DbAttribute (org.apache.cayenne.map.DbAttribute)8 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)7 DbRelationship (org.apache.cayenne.map.DbRelationship)6 ObjAttribute (org.apache.cayenne.map.ObjAttribute)6 ObjRelationship (org.apache.cayenne.map.ObjRelationship)6 Gallery (org.apache.cayenne.testdo.testmap.Gallery)6