@Test public void shouldNotGetCurrentPeriodIfProgramStartDateIsAfterCurrentPeriodEndDate() { Date currentDate = new Date(); ProcessingPeriod period1 = make( a( defaultProcessingPeriod, with(startDate, addDays(currentDate, -1)), with(endDate, addDays(currentDate, 5)), with(scheduleId, schedule.getId()), with(name, "Month1"))); mapper.insert(period1); Date programStartDate = addDays(period1.getStartDate(), 7); ProcessingPeriod actualPeriod = mapper.getCurrentPeriod(schedule.getId(), programStartDate); Assert.assertNull(actualPeriod); }
@Test public void shouldReturnNullIfCurrentPeriodDoesNotExist() { Date currentDate = new Date(); ProcessingPeriod period1 = make( a( defaultProcessingPeriod, with(startDate, addDays(currentDate, 2)), with(endDate, addDays(currentDate, 5)), with(scheduleId, schedule.getId()), with(name, "Month1"))); mapper.insert(period1); ProcessingPeriod actualPeriod = mapper.getCurrentPeriod(schedule.getId(), period1.getStartDate()); assertNull(actualPeriod); }
@Test public void shouldGetCurrentPeriodByFacilityAndProgram() { Date currentDate = new Date(); ProcessingPeriod period1 = make( a( defaultProcessingPeriod, with(startDate, addDays(currentDate, -1)), with(endDate, addDays(currentDate, 5)), with(scheduleId, schedule.getId()), with(name, "Month1"))); mapper.insert(period1); ProcessingPeriod actualPeriod = mapper.getCurrentPeriod(schedule.getId(), period1.getStartDate()); assertThat(actualPeriod, is(period1)); }