Search in sources :

Example 21 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class HolidayBOTest method testIsFutureRepayment.

@Test
public void testIsFutureRepayment() throws Exception {
    Holiday sameDayRepaymentHoliday = new HolidayBuilder().withName("holiday").from(new DateTime()).to(new DateTime()).withSameDayAsRule().build();
    Holiday nextMeetingDayRepaymentHoliday = new HolidayBuilder().withName("holiday").from(new DateTime()).to(new DateTime()).withNextMeetingRule().build();
    Holiday nextWorkingDayRepaymentHoliday = new HolidayBuilder().withName("holiday").from(new DateTime()).to(new DateTime()).withNextWorkingDayRule().build();
    Holiday moratoriumRepaymentHoliday = new HolidayBuilder().withName("holiday").from(new DateTime()).to(new DateTime()).withRepaymentMoratoriumRule().build();
    Assert.assertFalse(sameDayRepaymentHoliday.isFutureRepayment());
    Assert.assertTrue(nextMeetingDayRepaymentHoliday.isFutureRepayment());
    Assert.assertTrue(nextWorkingDayRepaymentHoliday.isFutureRepayment());
    Assert.assertTrue(moratoriumRepaymentHoliday.isFutureRepayment());
}
Also used : HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 22 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method nextDayRepaymentIsFutureRepaymentHoliday.

@Test
@Ignore
public void nextDayRepaymentIsFutureRepaymentHoliday() {
    DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
    Holiday nextDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withNextMeetingRule().build();
    insertHoliday(nextDayRepaymentHoliday);
    Assert.assertTrue(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method sameDayHolidayIsNotFutureRepaymentHoliday.

@Test
@Ignore
public void sameDayHolidayIsNotFutureRepaymentHoliday() {
    DateTime secondLastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
    Holiday sameDayRepaymentHoliday = new HolidayBuilder().from(secondLastDayOfYear).to(secondLastDayOfYear).withSameDayAsRule().build();
    insertHoliday(sameDayRepaymentHoliday);
    Assert.assertFalse(holidayDao.isFutureRepaymentHoliday((short) 1, secondLastDayOfYear.toLocalDate().toString()));
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method shouldfindCurrentAndFutureOfficeHolidaysEarliestFirst.

@Test
public void shouldfindCurrentAndFutureOfficeHolidaysEarliestFirst() throws Exception {
    DateTime yesterday = new DateTime().minusDays(1);
    Set<HolidayBO> holidays;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("Fourth").from(yesterday.plusWeeks(4)).to(yesterday.plusWeeks(5)).build());
    holidays.add((HolidayBO) new HolidayBuilder().withName("Second").from(yesterday.plusDays(1)).to(yesterday.plusWeeks(7)).build());
    headOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(headOffice);
    // builder not setting searchId correctly due to not going thru office.save (which uses HierarchyManager)
    String headOfficeSearchId = headOffice.getSearchId();
    OfficeBO areaOffice = new OfficeBuilder().withName("Area Office").withSearchId(headOfficeSearchId + "25.").withParentOffice(headOffice).withGlobalOfficeNum("area56").build();
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("Fifth").from(yesterday.plusWeeks(8)).to(yesterday.plusWeeks(9)).build());
    areaOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(areaOffice);
    OfficeBO myOffice = new OfficeBuilder().withName("My Office").withSearchId(headOfficeSearchId + "25.1.").withParentOffice(areaOffice).withGlobalOfficeNum("my001").build();
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("Third").from(yesterday.plusWeeks(3)).to(yesterday.plusWeeks(4)).build());
    holidays.add((HolidayBO) new HolidayBuilder().withName("First").from(yesterday).to(yesterday.plusWeeks(2)).build());
    myOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(myOffice);
    OfficeBO anotherOffice = new OfficeBuilder().withName("Another Unconnected Office").withSearchId(headOfficeSearchId + "26.").withParentOffice(headOffice).withGlobalOfficeNum("n/a001").build();
    holidays = new HashSet<HolidayBO>();
    holidays.add((HolidayBO) new HolidayBuilder().withName("N/A").from(yesterday.minusWeeks(3)).to(yesterday.plusWeeks(4)).build());
    anotherOffice.setHolidays(holidays);
    IntegrationTestObjectMother.createOffice(anotherOffice);
    List<Holiday> myHolidays = holidayDao.findCurrentAndFutureOfficeHolidaysEarliestFirst(myOffice.getOfficeId());
    assertThat(myHolidays.size(), is(5));
    assertThat(myHolidays.get(0).getName(), is("First"));
    assertThat(myHolidays.get(1).getName(), is("Second"));
    assertThat(myHolidays.get(2).getName(), is("Third"));
    assertThat(myHolidays.get(3).getName(), is("Fourth"));
    assertThat(myHolidays.get(4).getName(), is("Fifth"));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) Holiday(org.mifos.application.holiday.business.Holiday) HolidayBO(org.mifos.application.holiday.business.HolidayBO) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 25 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method shouldNotThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDoNotDifferFromPreviousParentOffice.

@Test
public void shouldNotThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDoNotDifferFromPreviousParentOffice() throws Exception {
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    DateTime tomorrow = new DateTime().plusDays(1);
    HolidayDetails holidayDetails = new HolidayBuilder().withName("areaOffice2Holiday").from(tomorrow).to(tomorrow).buildDto();
    IntegrationTestObjectMother.createHoliday(holidayDetails, Arrays.asList(areaOffice2.getOfficeId(), areaOffice1.getOfficeId()));
    HolidayDetails branchOnlyHolidayDetails = new HolidayBuilder().withName("branchOnlyHoliday").from(tomorrow).to(tomorrow).buildDto();
    IntegrationTestObjectMother.createHoliday(branchOnlyHolidayDetails, Arrays.asList(branch1.getOfficeId()));
    // refetch
    branch1 = IntegrationTestObjectMother.findOfficeById(branch1.getOfficeId());
    // exercise test
    holidayDao.validateNoExtraFutureHolidaysApplicableOnParentOffice(branch1.getParentOffice().getOfficeId(), areaOffice2.getOfficeId());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) HolidayDetails(org.mifos.dto.domain.HolidayDetails) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)35 Test (org.junit.Test)34 Holiday (org.mifos.application.holiday.business.Holiday)28 DateTime (org.joda.time.DateTime)16 Ignore (org.junit.Ignore)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 DateMidnight (org.joda.time.DateMidnight)6 HolidayBO (org.mifos.application.holiday.business.HolidayBO)4 ArrayList (java.util.ArrayList)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 Money (org.mifos.framework.util.helpers.Money)3 LocalDate (org.joda.time.LocalDate)2 GenericDao (org.mifos.accounts.savings.persistence.GenericDao)2 GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)2 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)2 HolidayDaoHibernate (org.mifos.application.holiday.persistence.HolidayDaoHibernate)2 OfficeDao (org.mifos.customers.office.persistence.OfficeDao)2 OfficeDaoHibernate (org.mifos.customers.office.persistence.OfficeDaoHibernate)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)2