use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class AggregationIntervalHelperImplTest method setUp.
@Before
public void setUp() {
when(eventAggregationManagementDao.getQuartersDetails()).thenReturn(EventDateTimeUtils.createStandardQuarters());
final List<AcademicTermDetail> terms = ImmutableList.<AcademicTermDetail>of(new AcademicTermDetailImpl(new DateMidnight(2012, 1, 12), new DateMidnight(2012, 4, 1), "spring 2"), new AcademicTermDetailImpl(new DateMidnight(2012, 4, 1), new DateMidnight(2012, 7, 1), "summer 2"), new AcademicTermDetailImpl(new DateMidnight(2012, 7, 1), new DateMidnight(2012, 12, 15), "fall 2"), new AcademicTermDetailImpl(new DateMidnight(2012, 12, 15), new DateMidnight(2013, 1, 14), "winter 2"), new AcademicTermDetailImpl(new DateMidnight(2015, 12, 15), new DateMidnight(2016, 1, 14), "winter 5"));
when(eventAggregationManagementDao.getAcademicTermDetails()).thenReturn(terms);
}
use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class EventDateTimeUtilsTest method testFindAcademicTerms.
@Test
public void testFindAcademicTerms() {
final AcademicTermDetailImpl spring2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2012, 6, 1), "Spring 2012");
final AcademicTermDetailImpl summer2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 6, 1), new DateMidnight(2012, 9, 1), "Summer 2012");
final AcademicTermDetailImpl fall2012 = new AcademicTermDetailImpl(new DateMidnight(2012, 9, 1), new DateMidnight(2013, 1, 1), "Fall 2012");
List<AcademicTermDetailImpl> terms = Arrays.asList(spring2012, summer2012, fall2012);
AcademicTermDetailImpl result;
Collections.sort(terms);
result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2011, 3, 1), terms);
assertNull(result);
result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 3, 1), terms);
assertEquals(spring2012, result);
result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 7, 1), terms);
assertEquals(summer2012, result);
result = EventDateTimeUtils.findDateRangeSorted(new DateMidnight(2012, 12, 31), terms);
assertEquals(fall2012, result);
}
use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class JpaDateTimeDimensionDaoTest method testGetMinMaxDateDimension.
@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());
}
});
}
use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class PortalEventDimensionPopulatorImpl method doPopulateDateDimensions.
final void doPopulateDateDimensions() {
final DateTime now = getNow();
final AggregationIntervalInfo startIntervalInfo;
final DateTime oldestPortalEventTimestamp = this.portalEventDao.getOldestPortalEventTimestamp();
if (oldestPortalEventTimestamp == null || now.isBefore(oldestPortalEventTimestamp)) {
startIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, now.minus(this.dimensionBuffer));
} else {
startIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, oldestPortalEventTimestamp.minus(this.dimensionBuffer));
}
final AggregationIntervalInfo endIntervalInfo;
final DateTime newestPortalEventTimestamp = this.portalEventDao.getNewestPortalEventTimestamp();
if (newestPortalEventTimestamp == null || now.isAfter(newestPortalEventTimestamp)) {
endIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, now.plus(this.dimensionBuffer));
} else {
endIntervalInfo = this.intervalHelper.getIntervalInfo(AggregationInterval.YEAR, newestPortalEventTimestamp.plus(this.dimensionBuffer));
}
final DateMidnight start = startIntervalInfo.getStart().toDateMidnight();
final DateMidnight end = endIntervalInfo.getEnd().toDateMidnight();
doPopulateDateDimensions(start, end);
}
use of org.joda.time.DateMidnight in project uPortal by Jasig.
the class DateDimensionImpl method getDate.
@Override
public DateMidnight getDate() {
DateMidnight dm = this.dateMidnight;
if (dm == null) {
dm = this.date.toDateMidnight();
this.dateMidnight = dm;
}
return dm;
}
Aggregations