Search in sources :

Example 61 with DateMidnight

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);
}
Also used : AcademicTermDetailImpl(org.apereo.portal.events.aggr.dao.jpa.AcademicTermDetailImpl) DateMidnight(org.joda.time.DateMidnight) Before(org.junit.Before)

Example 62 with DateMidnight

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);
}
Also used : DateMidnight(org.joda.time.DateMidnight) Test(org.junit.Test)

Example 63 with DateMidnight

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());
        }
    });
}
Also used : DateMidnight(org.joda.time.DateMidnight) List(java.util.List) DateDimension(org.apereo.portal.events.aggr.DateDimension) CallableWithoutResult(org.apereo.portal.concurrency.CallableWithoutResult) Test(org.junit.Test) BaseAggrEventsJpaDaoTest(org.apereo.portal.test.BaseAggrEventsJpaDaoTest)

Example 64 with DateMidnight

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);
}
Also used : DateMidnight(org.joda.time.DateMidnight) DateTime(org.joda.time.DateTime)

Example 65 with DateMidnight

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;
}
Also used : DateMidnight(org.joda.time.DateMidnight)

Aggregations

DateMidnight (org.joda.time.DateMidnight)70 DateTime (org.joda.time.DateTime)33 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)10 Money (org.mifos.framework.util.helpers.Money)10 Ignore (org.junit.Ignore)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 LocalDate (org.joda.time.LocalDate)6 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)6 Holiday (org.mifos.application.holiday.business.Holiday)6 Date (java.util.Date)5 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)5 AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)4 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)4 UserContext (org.mifos.security.util.UserContext)4 DateTimeZone (org.joda.time.DateTimeZone)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 Before (org.junit.Before)3