use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTExtractIT method testSecond.
@Test
public void testSecond() {
Expression exp = ExpressionFactory.exp("second(timestampColumn) = 39");
try {
long res = ObjectSelect.query(DateTestEntity.class, exp).selectCount(context);
assertEquals(1, res);
} catch (CayenneRuntimeException e) {
if (unitDbAdapter.supportsExtractPart(ASTExtract.DateTimePart.SECOND)) {
throw e;
}
}
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTExtractIT method testWeek.
@Test
public void testWeek() {
// 13 or 14 depends of first day in week in current db
Expression exp = ExpressionFactory.exp("week(dateColumn) in (13, 14)");
try {
long res = ObjectSelect.query(DateTestEntity.class, exp).selectCount(context);
assertEquals(1, res);
} catch (CayenneRuntimeException e) {
if (unitDbAdapter.supportsExtractPart(ASTExtract.DateTimePart.WEEK)) {
throw e;
}
// else ok
}
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTExtractTest method testSecond.
@Test
public void testSecond() {
String expStr = "second(dateColumn)";
Expression expParsed = ExpressionFactory.exp(expStr);
Expression expFromFactory = FunctionExpressionFactory.secondExp("dateColumn");
assertTrue(expParsed instanceof ASTExtract);
assertTrue(expFromFactory instanceof ASTExtract);
assertEquals(expStr, expParsed.toString());
assertEquals(expStr, expFromFactory.toString());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTExtractTest method testDayOfYear.
@Test
public void testDayOfYear() {
String expStr = "dayOfYear(dateColumn)";
Expression expParsed = ExpressionFactory.exp(expStr);
Expression expFromFactory = FunctionExpressionFactory.dayOfYearExp("dateColumn");
assertTrue(expParsed instanceof ASTExtract);
assertTrue(expFromFactory instanceof ASTExtract);
assertEquals(expStr, expParsed.toString());
assertEquals(expStr, expFromFactory.toString());
}
use of org.apache.cayenne.exp.Expression in project cayenne by apache.
the class ASTExtractTest method testMonth.
@Test
public void testMonth() {
String expStr = "month(dateColumn)";
Expression expParsed = ExpressionFactory.exp(expStr);
Expression expFromFactory = FunctionExpressionFactory.monthExp("dateColumn");
assertTrue(expParsed instanceof ASTExtract);
assertTrue(expFromFactory instanceof ASTExtract);
assertEquals(expStr, expParsed.toString());
assertEquals(expStr, expFromFactory.toString());
}
Aggregations