use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeIgnoreCaseTest method testEvaluateUnicode.
@Test
public void testEvaluateUnicode() {
Expression like = new ASTLikeIgnoreCase(new ASTObjPath("artistName"), "ÀБĞÞ%");
Expression notLike = new ASTNotLikeIgnoreCase(new ASTObjPath("artistName"), "ÀБĞÞ%");
Artist noMatch1 = new Artist();
noMatch1.setArtistName("àbğþ");
assertFalse(like.match(noMatch1));
assertTrue(notLike.match(noMatch1));
Artist match1 = new Artist();
match1.setArtistName("àбğþd");
assertTrue("Failed: " + like, like.match(match1));
assertFalse("Failed: " + notLike, notLike.match(match1));
Artist match2 = new Artist();
match2.setArtistName("àБğÞ");
assertTrue("Failed: " + like, like.match(match2));
assertFalse("Failed: " + notLike, notLike.match(match2));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeIgnoreCaseTest method testEvaluate.
@Test
public void testEvaluate() {
Expression like = new ASTLikeIgnoreCase(new ASTObjPath("artistName"), "aBcD");
Expression notLike = new ASTNotLikeIgnoreCase(new ASTObjPath("artistName"), "aBcD");
Artist noMatch1 = new Artist();
noMatch1.setArtistName("dabc");
assertFalse(like.match(noMatch1));
assertTrue(notLike.match(noMatch1));
Artist match1 = new Artist();
match1.setArtistName("abcd");
assertTrue("Failed: " + like, like.match(match1));
assertFalse("Failed: " + notLike, notLike.match(match1));
Artist match2 = new Artist();
match2.setArtistName("ABcD");
assertTrue("Failed: " + like, like.match(match2));
assertFalse("Failed: " + notLike, notLike.match(match2));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeIgnoreCaseTest method testEvaluateWithCollection.
@Test
public void testEvaluateWithCollection() {
Expression like = new ASTLikeIgnoreCase(new ASTObjPath("paintingArray.paintingTitle"), "aBcD");
Expression notLike = new ASTNotLikeIgnoreCase(new ASTObjPath("paintingArray.paintingTitle"), "aBcD");
Artist noMatch1 = new Artist();
noMatch1.writePropertyDirectly("paintingArray", Arrays.asList(createPainting("xyz"), createPainting("abc")));
assertFalse("Failed: " + like, like.match(noMatch1));
assertTrue("Failed: " + like, notLike.match(noMatch1));
Artist match1 = new Artist();
match1.writePropertyDirectly("paintingArray", Arrays.asList(createPainting("AbCd"), createPainting("abcd")));
assertTrue("Failed: " + like, like.match(match1));
assertFalse("Failed: " + like, notLike.match(match1));
Artist match2 = new Artist();
match2.writePropertyDirectly("paintingArray", Arrays.asList(createPainting("Xzy"), createPainting("abcd")));
assertTrue("Failed: " + like, like.match(match2));
assertTrue("Failed: " + like, notLike.match(match2));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeTest method testEvaluate_NotSoSpecialChars.
@Test
public void testEvaluate_NotSoSpecialChars() {
// test special chars that are not LIKE pattern match chars
Expression like = new ASTLike(new ASTObjPath("artistName"), "/./");
Artist noMatch1 = new Artist();
noMatch1.setArtistName("/a/");
assertFalse(like.match(noMatch1));
Artist match = new Artist();
match.setArtistName("/./");
assertTrue("Failed: " + like, like.match(match));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeTest method testToEJBQL_likeEscape.
@Test
public void testToEJBQL_likeEscape() throws IOException {
Expression like = new ASTLike(new ASTObjPath("mainName"), "|%|%?|_title|%", '|');
assertEquals("x.mainName like '|%|%?|_title|%' escape '|'", like.toEJBQL("x"));
}
Aggregations