Search in sources :

Example 1 with ASTSubstring

use of org.apache.cayenne.exp.parser.ASTSubstring in project cayenne by apache.

the class FunctionExpressionFactoryTest method substringExp.

@Test
public void substringExp() throws Exception {
    Expression exp1 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.path(), 10, 15);
    Expression exp2 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.getName(), 10, 15);
    Expression exp3 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.path(), new ASTScalar(10), new ASTScalar(15));
    assertTrue(exp1 instanceof ASTSubstring);
    assertEquals(3, exp1.getOperandCount());
    assertEquals(Artist.ARTIST_NAME.path(), exp1.getOperand(0));
    assertEquals(10, exp1.getOperand(1));
    assertEquals(15, exp1.getOperand(2));
    assertEquals(exp1, exp2);
    assertEquals(exp2, exp3);
}
Also used : ASTSubstring(org.apache.cayenne.exp.parser.ASTSubstring) ASTScalar(org.apache.cayenne.exp.parser.ASTScalar) Test(org.junit.Test)

Aggregations

ASTScalar (org.apache.cayenne.exp.parser.ASTScalar)1 ASTSubstring (org.apache.cayenne.exp.parser.ASTSubstring)1 Test (org.junit.Test)1