Search in sources :

Example 11 with ASTLike

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

the class LikeExpressionHelperTest method testEscape_TwoChars.

@Test
public void testEscape_TwoChars() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "ab_c_");
    LikeExpressionHelper.escape(node);
    assertEquals("ab!_c!_", node.getOperand(1));
    assertEquals('!', node.getEscapeChar());
}
Also used : ASTObjPath(org.apache.cayenne.exp.parser.ASTObjPath) ASTLike(org.apache.cayenne.exp.parser.ASTLike) PatternMatchNode(org.apache.cayenne.exp.parser.PatternMatchNode) Test(org.junit.Test)

Example 12 with ASTLike

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

the class LikeExpressionHelperTest method testEscape_AltEscapeChar1.

@Test
public void testEscape_AltEscapeChar1() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "a!%c");
    LikeExpressionHelper.escape(node);
    assertEquals("a!#%c", node.getOperand(1));
    assertEquals('#', node.getEscapeChar());
}
Also used : ASTObjPath(org.apache.cayenne.exp.parser.ASTObjPath) ASTLike(org.apache.cayenne.exp.parser.ASTLike) PatternMatchNode(org.apache.cayenne.exp.parser.PatternMatchNode) Test(org.junit.Test)

Aggregations

ASTLike (org.apache.cayenne.exp.parser.ASTLike)12 ASTObjPath (org.apache.cayenne.exp.parser.ASTObjPath)6 PatternMatchNode (org.apache.cayenne.exp.parser.PatternMatchNode)6 Test (org.junit.Test)6