use of java.util.Calendar in project head by mifos.
the class HolidayServiceTest method shouldDetermineIfActualHolidayIsNotWorkingDay.
@Test
public void shouldDetermineIfActualHolidayIsNotWorkingDay() {
Calendar holiday = toCalendar("01-Nov-2010");
DateTime holidayAsDateTime = new DateTime(holiday.getTime().getTime());
String holidayAsString = holidayAsDateTime.toLocalDate().toString();
when(fiscalCalendarRules.isWorkingDay(holiday)).thenReturn(true);
when(holidayDao.isHoliday(officeId, holidayAsString)).thenReturn(true);
assertThat(holidayService.isWorkingDay(holiday, officeId), is(false));
verify(fiscalCalendarRules, times(1)).isWorkingDay(holiday);
verify(holidayDao).isHoliday(officeId, holidayAsString);
}
use of java.util.Calendar in project head by mifos.
the class MifosMockStrutsTestCase method addRequestDateParameter.
protected void addRequestDateParameter(String param, String dateStr) throws InvalidDateException {
java.sql.Date date = DateUtils.getDateAsSentFromBrowser(dateStr);
if (date != null) {
Calendar cal = new GregorianCalendar();
cal.setTime(date);
addRequestParameter(param + "DD", Integer.toString(cal.get(Calendar.DAY_OF_MONTH)));
addRequestParameter(param + "MM", Integer.toString(cal.get(Calendar.MONTH) + 1));
addRequestParameter(param + "YY", Integer.toString(cal.get(Calendar.YEAR)));
} else {
addRequestParameter(param + "DD", "");
addRequestParameter(param + "MM", "");
addRequestParameter(param + "YY", "");
}
}
use of java.util.Calendar in project head by mifos.
the class LoanArrearsHelperIntegrationTest method offSetCurrentDate.
private java.sql.Date offSetCurrentDate(int noOfDays) {
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 - noOfDays);
return new java.sql.Date(currentDateCalendar.getTimeInMillis());
}
use of java.util.Calendar in project head by mifos.
the class LoanArrearsTaskIntegrationTest method offSetCurrentDate.
private java.sql.Date offSetCurrentDate(int noOfDays) {
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 - noOfDays);
return new java.sql.Date(currentDateCalendar.getTimeInMillis());
}
use of java.util.Calendar in project head by mifos.
the class BatchJobCatchUpIntegrationTest method testIncompleteTaskDelay.
@Test
public void testIncompleteTaskDelay() throws Exception {
mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/catchUpTask.xml");
Scheduler scheduler = mifosScheduler.getScheduler();
ProductStatus productStatusTask = new ProductStatus();
productStatusTask.setJobExplorer(mifosScheduler.getBatchJobExplorer());
productStatusTask.setJobLauncher(mifosScheduler.getBatchJobLauncher());
productStatusTask.setJobLocator(mifosScheduler.getBatchJobLocator());
productStatusTask.setJobRepository(mifosScheduler.getBatchJobRepository());
String quartzJobName = "ProductStatusJob";
String quartzTriggerName = "ProductStatusTrigger2";
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.SECOND, 10);
Date previousFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 21);
Date quartzFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 22);
Date quartzNextFireTime = calendar.getTime();
calendar.set(Calendar.SECOND, 20);
Date quartzPrevFireTime = calendar.getTime();
JobDetail jobDetail = scheduler.getJobDetail(quartzJobName, Scheduler.DEFAULT_GROUP);
jobDetail.setJobDataMap(new JobDataMap());
CronTrigger trigger = new CronTrigger(quartzTriggerName, Scheduler.DEFAULT_GROUP, quartzJobName, Scheduler.DEFAULT_GROUP, "* * * * * ?");
trigger.setJobDataMap(new JobDataMap());
TriggerFiredBundle triggerFiredBundle = new TriggerFiredBundle(jobDetail, trigger, new BaseCalendar(), false, quartzFireTime, quartzFireTime, quartzPrevFireTime, quartzNextFireTime);
JobExecutionContext jobExecutionContext = new JobExecutionContext(scheduler, triggerFiredBundle, productStatusTask);
JobLauncher jobLauncher = mifosScheduler.getBatchJobLauncher();
JobLocator jobLocator = mifosScheduler.getBatchJobLocator();
jobLauncher.run(jobLocator.getJob(jobName), MifosBatchJob.createJobParameters(previousFireTime.getTime()));
Thread.sleep(1500);
productStatusTask.catchUpMissedLaunches(jobLocator.getJob(jobName), jobExecutionContext);
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 20);
Assert.assertEquals(11, jobInstances.size());
for (JobInstance jobInstance : jobInstances) {
List<JobExecution> jobExecutions = explorer.getJobExecutions(jobInstance);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecutions.get(0).getStatus());
Assert.assertEquals(calendar.getTimeInMillis(), jobInstance.getJobParameters().getLong(MifosBatchJob.JOB_EXECUTION_TIME_KEY));
calendar.roll(Calendar.SECOND, false);
}
}
Aggregations