@Test
public void testGetMinMaxDateDimension() {
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final DateDimension newestDateDimension = dateDimensionDao.getNewestDateDimension();
assertNull(newestDateDimension);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensions();
assertEquals(Collections.EMPTY_LIST, dateDimensions);
}
});
this.executeInTransaction(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
DateMidnight date = new DateMidnight(2012, 1, 1);
for (int i = 0; i < 7; i++) {
dateDimensionDao.createDateDimension(date, 0, null);
date = date.plusDays(1);
}
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
DateMidnight date = new DateMidnight(2012, 1, 1);
final DateDimension dateDimension = dateDimensionDao.getDateDimensionByDate(date);
assertNotNull(dateDimension);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensions();
assertEquals(7, dateDimensions.size());
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final DateMidnight start = new DateMidnight(2012, 1, 2);
final DateMidnight end = new DateMidnight(2012, 1, 6);
final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensionsBetween(start, end);
assertEquals(4, dateDimensions.size());
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final DateDimension oldestDateDimension = dateDimensionDao.getOldestDateDimension();
assertEquals(2012, oldestDateDimension.getYear());
assertEquals(1, oldestDateDimension.getMonth());
assertEquals(1, oldestDateDimension.getDay());
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final DateDimension newestDateDimension = dateDimensionDao.getNewestDateDimension();
assertEquals(2012, newestDateDimension.getYear());
assertEquals(1, newestDateDimension.getMonth());
assertEquals(7, newestDateDimension.getDay());
}
});
}