Search in sources :

Example 1 with PatternMatchNode

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

the class LikeExpressionHelperTest method testEscape_TwoChars_Mix.

@Test
public void testEscape_TwoChars_Mix() {
    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 2 with PatternMatchNode

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

the class LikeExpressionHelperTest method testEscape_AltEscapeChar2.

@Test
public void testEscape_AltEscapeChar2() {
    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)

Example 3 with PatternMatchNode

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

the class LikeExpressionHelperTest method testEscape_OneChar.

@Test
public void testEscape_OneChar() {
    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 4 with PatternMatchNode

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

the class LikeExpressionHelperTest method testEscape_NoEscapeChars.

@Test
public void testEscape_NoEscapeChars() {
    PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "abc");
    LikeExpressionHelper.escape(node);
    assertEquals("abc", node.getOperand(1));
    assertEquals(0, 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 5 with PatternMatchNode

use of org.apache.cayenne.exp.parser.PatternMatchNode 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)

Aggregations

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