use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class ASTEqualTest method testEvaluate_BigDecimal.
@Test
public void testEvaluate_BigDecimal() {
BigDecimal bd1 = new BigDecimal("2.0");
BigDecimal bd2 = new BigDecimal("2.0");
BigDecimal bd3 = new BigDecimal("2.00");
BigDecimal bd4 = new BigDecimal("2.01");
ASTEqual equalTo = new ASTEqual(new ASTObjPath(Painting.ESTIMATED_PRICE.getName()), bd1);
Painting p = new Painting();
p.setEstimatedPrice(bd2);
assertTrue(equalTo.match(p));
// BigDecimals must compare regardless of the number of trailing zeros
// (see CAY-280)
p.setEstimatedPrice(bd3);
assertTrue(equalTo.match(p));
p.setEstimatedPrice(bd4);
assertFalse(equalTo.match(p));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class ASTGreaterOrEqualTest method testEvaluate_Null.
@Test
public void testEvaluate_Null() {
Expression gtNull = new ASTGreaterOrEqual(new ASTObjPath("estimatedPrice"), null);
Expression gtNotNull = new ASTGreaterOrEqual(new ASTObjPath("estimatedPrice"), new BigDecimal(10000d));
Painting noMatch = new Painting();
assertFalse(gtNull.match(noMatch));
assertFalse(gtNotNull.match(noMatch));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class ASTInTest method testEvaluate_Null.
@Test
public void testEvaluate_Null() {
Expression in = new ASTIn(new ASTObjPath("estimatedPrice"), new ASTList(new Object[] { new BigDecimal("10"), new BigDecimal("20") }));
Expression notIn = new ASTNotIn(new ASTObjPath("estimatedPrice"), new ASTList(new Object[] { new BigDecimal("10"), new BigDecimal("20") }));
Painting noMatch = new Painting();
assertFalse(in.match(noMatch));
assertFalse(notIn.match(noMatch));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class ASTLessTest method testEvaluate.
@Test
public void testEvaluate() {
Expression e = new ASTLess(new ASTObjPath("estimatedPrice"), new BigDecimal(10000d));
Painting noMatch = new Painting();
noMatch.setEstimatedPrice(new BigDecimal(10001));
assertFalse("Failed: " + e, e.match(noMatch));
Painting noMatch1 = new Painting();
noMatch1.setEstimatedPrice(new BigDecimal(10000));
assertFalse("Failed: " + e, e.match(noMatch1));
Painting match = new Painting();
match.setEstimatedPrice(new BigDecimal(9999));
assertTrue("Failed: " + e, e.match(match));
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class ColumnSelectIT method testObjPropertyInWhere.
@Test
public void testObjPropertyInWhere() {
Artist artist = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.eq("artist1")).selectFirst(context);
Property<Painting> paintingProperty = Property.createSelf(Painting.class);
List<Painting> result = ObjectSelect.query(Painting.class).column(paintingProperty).where(Painting.TO_ARTIST.eq(artist)).select(context);
assertEquals(4, result.size());
}
Aggregations