Search in sources :

Example 81 with Expression

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()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 82 with Expression

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()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 83 with Expression

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));
}
Also used : Expression(org.apache.cayenne.exp.Expression) BigDecimal(java.math.BigDecimal) Painting(org.apache.cayenne.testdo.testmap.Painting) Test(org.junit.Test)

Example 84 with Expression

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));
}
Also used : Expression(org.apache.cayenne.exp.Expression) BigDecimal(java.math.BigDecimal) Painting(org.apache.cayenne.testdo.testmap.Painting) Test(org.junit.Test)

Example 85 with Expression

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));
}
Also used : Expression(org.apache.cayenne.exp.Expression) BigDecimal(java.math.BigDecimal) Painting(org.apache.cayenne.testdo.testmap.Painting) 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