Search in sources :

Example 6 with HolidayDetails

use of org.mifos.dto.domain.HolidayDetails in project head by mifos.

the class HolidayServiceIntegrationTest method shouldCreateHolidayAgainstOfficesOfDifferentLevelThatDoNotExistInSameOfficeHierarchySubTree.

@Test
public void shouldCreateHolidayAgainstOfficesOfDifferentLevelThatDoNotExistInSameOfficeHierarchySubTree() throws Exception {
    // setup
    HolidayDetails holidayDetails = new HolidayDetails("test", new DateTime().plusDays(1).toDate(), new DateTime().plusDays(1).toDate(), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT.getValue());
    List<Short> officeIds = Arrays.asList(areaOffice.getOfficeId(), branch3.getOfficeId());
    // exercise test
    holidayService.create(holidayDetails, officeIds);
}
Also used : HolidayDetails(org.mifos.dto.domain.HolidayDetails) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 7 with HolidayDetails

use of org.mifos.dto.domain.HolidayDetails in project head by mifos.

the class HolidayServiceIntegrationTest method shouldFailToCreateHolidayAgainstOfficesOfDifferentLevelThatExistInSameOfficeHierarchySubTree.

@Test(expected = BusinessRuleException.class)
public void shouldFailToCreateHolidayAgainstOfficesOfDifferentLevelThatExistInSameOfficeHierarchySubTree() throws Exception {
    // setup
    HolidayDetails holidayDetails = new HolidayDetails("test", new DateTime().plusDays(1).toDate(), new DateTime().plusDays(1).toDate(), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT.getValue());
    List<Short> officeIds = Arrays.asList(headOffice.getOfficeId(), regionalOffice.getOfficeId());
    // exercise test
    holidayService.create(holidayDetails, officeIds);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : HolidayDetails(org.mifos.dto.domain.HolidayDetails) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 8 with HolidayDetails

use of org.mifos.dto.domain.HolidayDetails in project head by mifos.

the class HolidayDaoHibernateIntegrationTest method insertHoliday.

private void insertHoliday(final Holiday holiday) {
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    HolidayDetails holidayDetails = new HolidayDetails("HolidayDaoTest", holiday.getFromDate().toDate(), holiday.getThruDate().toDate(), holiday.getRepaymentRuleType().getValue());
    List<Short> officeIds = Arrays.asList(headOffice.getOfficeId());
    IntegrationTestObjectMother.createHoliday(holidayDetails, officeIds);
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) HolidayDetails(org.mifos.dto.domain.HolidayDetails)

Example 9 with HolidayDetails

use of org.mifos.dto.domain.HolidayDetails 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)

Example 10 with HolidayDetails

use of org.mifos.dto.domain.HolidayDetails in project head by mifos.

the class HolidayServiceFacadeWebTierTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    String name = "testHoliday";
    DateTime dateTime = new DateTime();
    Date fromDate = dateTime.plusDays(10).toDate();
    Date thruDate = dateTime.plusDays(20).toDate();
    RepaymentRuleTypes repaymentRule = RepaymentRuleTypes.SAME_DAY;
    holidayDetails = new HolidayDetails(name, fromDate, thruDate, repaymentRule.getValue());
    holidayServiceFacade = new HolidayServiceFacadeWebTier(holidayService, holidayDao);
    locale = new Locale("en", "GB");
    dateFormat = computeDateFormat(locale);
    officeId = Short.valueOf("1");
}
Also used : Locale(java.util.Locale) RepaymentRuleTypes(org.mifos.application.holiday.util.helpers.RepaymentRuleTypes) HolidayDetails(org.mifos.dto.domain.HolidayDetails) DateTime(org.joda.time.DateTime) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) Before(org.junit.Before)

Aggregations

HolidayDetails (org.mifos.dto.domain.HolidayDetails)12 DateTime (org.joda.time.DateTime)7 Test (org.junit.Test)5 LinkedList (java.util.LinkedList)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 Date (java.util.Date)2 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 TreeMap (java.util.TreeMap)1 LocalDate (org.joda.time.LocalDate)1 Before (org.junit.Before)1 HolidayBO (org.mifos.application.holiday.business.HolidayBO)1 RepaymentRuleTypes (org.mifos.application.holiday.util.helpers.RepaymentRuleTypes)1 MessageLookup (org.mifos.application.master.MessageLookup)1 OfficeHoliday (org.mifos.dto.domain.OfficeHoliday)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1