use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeTest method testEvaluate_SingleCharMatch.
@Test
public void testEvaluate_SingleCharMatch() {
Expression like = new ASTLike(new ASTObjPath("artistName"), "abc?d");
Expression notLike = new ASTNotLike(new ASTObjPath("artistName"), "abc?d");
Artist noMatch1 = new Artist();
noMatch1.setArtistName("dabc");
assertFalse(like.match(noMatch1));
assertTrue(notLike.match(noMatch1));
Artist noMatch2 = new Artist();
noMatch2.setArtistName("abc123d");
assertFalse("Failed: " + like, like.match(noMatch2));
assertTrue("Failed: " + notLike, notLike.match(noMatch2));
Artist match = new Artist();
match.setArtistName("abcXd");
assertTrue("Failed: " + like, like.match(match));
assertFalse("Failed: " + notLike, notLike.match(match));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTLikeTest method testEvaluateUnicode.
@Test
public void testEvaluateUnicode() {
Expression like = new ASTLike(new ASTObjPath("artistName"), "àбğþ%");
Expression notLike = new ASTNotLike(new ASTObjPath("artistName"), "àбğþ%");
Artist noMatch1 = new Artist();
noMatch1.setArtistName("àbğþd");
assertFalse(like.match(noMatch1));
assertTrue(notLike.match(noMatch1));
Artist match1 = new Artist();
match1.setArtistName("àбğþ");
assertTrue("Failed: " + like, like.match(match1));
assertFalse("Failed: " + notLike, notLike.match(match1));
Artist match2 = new Artist();
match2.setArtistName("àбğþa");
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 ASTLocateTest method parseTest.
@Test
public void parseTest() throws Exception {
String expString = "locate(\"xyz\" , abc , 4)";
Expression exp = ExpressionFactory.exp(expString);
assertTrue(exp instanceof ASTLocate);
String toString = exp.toString();
assertEquals(expString, toString);
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTNotEqualTest method testEvaluate.
@Test
public void testEvaluate() {
Expression notEqualTo = new ASTNotEqual(new ASTObjPath("artistName"), "abc");
Artist match = new Artist();
match.setArtistName("abc");
assertFalse(notEqualTo.match(match));
Artist noMatch = new Artist();
noMatch.setArtistName("123");
assertTrue("Failed: " + notEqualTo, notEqualTo.match(noMatch));
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTOrTest method testEvaluateOR.
@Test
public void testEvaluateOR() {
Expression e1 = new ASTEqual(new ASTObjPath("artistName"), "abc");
Expression e2 = new ASTEqual(new ASTObjPath("artistName"), "xyz");
ASTOr e = new ASTOr(new Object[] { e1, e2 });
Artist match1 = new Artist();
match1.setArtistName("abc");
assertTrue("Failed: " + e, e.match(match1));
Artist match2 = new Artist();
match2.setArtistName("xyz");
assertTrue("Failed: " + e, e.match(match2));
Artist noMatch = new Artist();
noMatch.setArtistName("123");
assertFalse("Failed: " + e, e.match(noMatch));
}
Aggregations