Search in sources :

Example 46 with Expression

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

the class SelectQueryTest method testOrQualifier.

@Test
public void testOrQualifier() {
    assertNull(query.getQualifier());
    Expression e1 = ExpressionFactory.expressionOfType(Expression.EQUAL_TO);
    query.orQualifier(e1);
    assertSame(e1, query.getQualifier());
    Expression e2 = ExpressionFactory.expressionOfType(Expression.NOT_EQUAL_TO);
    query.orQualifier(e2);
    assertEquals(Expression.OR, query.getQualifier().getType());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 47 with Expression

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

the class SelectQueryTest method testSetQualifier.

@Test
public void testSetQualifier() {
    assertNull(query.getQualifier());
    Expression qual = ExpressionFactory.expressionOfType(Expression.AND);
    query.setQualifier(qual);
    assertNotNull(query.getQualifier());
    assertSame(qual, query.getQualifier());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 48 with Expression

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

the class ASTAbsTest method parseTest.

@Test
public void parseTest() throws Exception {
    String expString = "abs(xyz)";
    Expression exp = ExpressionFactory.exp(expString);
    assertTrue(exp instanceof ASTAbs);
    String toString = exp.toString();
    assertEquals(expString, toString);
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 49 with Expression

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

the class ASTAggregateTest method testAvgParse.

@Test
public void testAvgParse() throws Exception {
    String expressionString = "avg(artistName)";
    Expression exp = ExpressionFactory.exp(expressionString);
    assertTrue(exp instanceof ASTAvg);
    assertEquals(1, exp.getOperandCount());
    assertTrue(exp.getOperand(0) instanceof ASTObjPath);
    assertEquals(expressionString, exp.toString());
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 50 with Expression

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

the class ASTAggregateTest method testSumParse.

@Test
public void testSumParse() throws Exception {
    String expressionString = "sum(artistName)";
    Expression exp = ExpressionFactory.exp(expressionString);
    assertTrue(exp instanceof ASTSum);
    assertEquals(1, exp.getOperandCount());
    assertTrue(exp.getOperand(0) instanceof ASTObjPath);
    assertEquals(expressionString, exp.toString());
}
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