use of java.util.Calendar in project head by mifos.
the class AccountBO method changeFirstInstallmentDateBy.
public void changeFirstInstallmentDateBy(final int numberOfDays) {
Calendar currentDateCalendar = new GregorianCalendar();
int year = currentDateCalendar.get(Calendar.YEAR);
int month = currentDateCalendar.get(Calendar.MONTH);
int day = currentDateCalendar.get(Calendar.DAY_OF_MONTH);
currentDateCalendar = new GregorianCalendar(year, month, day + numberOfDays);
changeActionDateOfFirstInstallment(currentDateCalendar, getAccountActionDates());
}
use of java.util.Calendar in project head by mifos.
the class HolidayServiceFacadeWebTierTest method isFutureRepaymentHoliday.
@Test
public void isFutureRepaymentHoliday() {
Calendar dueDate = toCalendar("01-Nov-2010");
when(holidayService.isFutureRepaymentHoliday(dueDate, officeId)).thenReturn(true);
Assert.assertTrue(holidayServiceFacade.isFutureRepaymentHoliday(officeId, dueDate));
verify(holidayService, times(1)).isFutureRepaymentHoliday(dueDate, officeId);
}
use of java.util.Calendar in project head by mifos.
the class HolidayServiceTest method shouldGetTheSameDayIfAlreadyWorkingDay.
@Test
public void shouldGetTheSameDayIfAlreadyWorkingDay() {
Calendar workingDay = toCalendar("01-Nov-2010");
DateTime holidayAsDateTime = new DateTime(workingDay.getTime().getTime());
String holidayAsString = holidayAsDateTime.toLocalDate().toString();
when(fiscalCalendarRules.isWorkingDay(workingDay)).thenReturn(true);
when(holidayDao.isHoliday(officeId, holidayAsString)).thenReturn(false);
Calendar nextWorkingDay = holidayService.getNextWorkingDay(toCalendar("01-Nov-2010"), officeId);
assertThat(nextWorkingDay, is(workingDay));
verify(fiscalCalendarRules, times(1)).isWorkingDay(workingDay);
verify(holidayDao).isHoliday(officeId, holidayAsString);
}
use of java.util.Calendar in project head by mifos.
the class HolidayServiceTest method shouldDetermineIfRegularHolidayIsNotWorkingDay.
@Test
public void shouldDetermineIfRegularHolidayIsNotWorkingDay() {
Calendar holiday = toCalendar("01-Nov-2010");
when(fiscalCalendarRules.isWorkingDay(holiday)).thenReturn(false);
assertThat(holidayService.isWorkingDay(holiday, officeId), is(false));
verify(fiscalCalendarRules, times(1)).isWorkingDay(holiday);
}
use of java.util.Calendar in project head by mifos.
the class HolidayServiceTest method shouldGetNextWorkingDay.
@Test
public void shouldGetNextWorkingDay() {
Calendar holiday1 = toCalendar("01-Nov-2010");
when(fiscalCalendarRules.isWorkingDay(holiday1)).thenReturn(false);
Calendar holiday2 = toCalendar("02-Nov-2010");
DateTime holiday2AsDateTime = new DateTime(holiday2.getTime().getTime());
String holiday2AsString = holiday2AsDateTime.toLocalDate().toString();
when(fiscalCalendarRules.isWorkingDay(holiday2)).thenReturn(true);
when(holidayDao.isHoliday(officeId, holiday2AsString)).thenReturn(true);
Calendar holiday3 = toCalendar("03-Nov-2010");
DateTime holiday3AsDateTime = new DateTime(holiday3.getTime().getTime());
String holiday3AsString = holiday3AsDateTime.toLocalDate().toString();
when(fiscalCalendarRules.isWorkingDay(holiday3)).thenReturn(true);
when(holidayDao.isHoliday(officeId, holiday3AsString)).thenReturn(true);
Calendar workingDay = toCalendar("04-Nov-2010");
DateTime holidayAsDateTime = new DateTime(workingDay.getTime().getTime());
String holidayAsString = holidayAsDateTime.toLocalDate().toString();
when(fiscalCalendarRules.isWorkingDay(workingDay)).thenReturn(true);
when(holidayDao.isHoliday(officeId, holidayAsString)).thenReturn(false);
Calendar nextWorkingDay = holidayService.getNextWorkingDay(toCalendar("01-Nov-2010"), officeId);
assertThat(nextWorkingDay.get(Calendar.DAY_OF_MONTH), is(4));
assertThat(nextWorkingDay.get(Calendar.MONTH), is(10));
assertThat(nextWorkingDay.get(Calendar.YEAR), is(2010));
verify(fiscalCalendarRules, times(4)).isWorkingDay(Matchers.<Calendar>anyObject());
verify(holidayDao, times(3)).isHoliday(Matchers.anyShort(), Matchers.anyString());
}
Aggregations