@Test public void shouldGetAllRelevantPeriodsAfterAGivenDateAndPeriod() throws Exception { Long requisitionGroupId = 1L; Long programId = 2L; Long facilityId = 3L; Long scheduleId = 4L; Long startingPeriodId = 5L; Date programStartDate = new DateTime().toDate(); List<ProcessingPeriod> periodList = asList(make(a(defaultProcessingPeriod))); RequisitionGroup requisitionGroup = make(a(RequisitionGroupBuilder.defaultRequisitionGroup)); requisitionGroup.setId(requisitionGroupId); when(requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(new Program(programId), new Facility(facilityId))).thenReturn(requisitionGroup); RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = make(a(defaultRequisitionGroupProgramSchedule)); ProcessingSchedule processingSchedule = new ProcessingSchedule(); processingSchedule.setId(scheduleId); requisitionGroupProgramSchedule.setProcessingSchedule(processingSchedule); when(requisitionGroupProgramScheduleRepository.getScheduleForRequisitionGroupAndProgram(requisitionGroupId, programId)).thenReturn(requisitionGroupProgramSchedule); when(periodRepository.getAllPeriodsAfterDateAndPeriod(any(Long.class), any(Long.class), any(Date.class), any(Date.class))).thenReturn(periodList); List<ProcessingPeriod> periods = service.getAllPeriodsAfterDateAndPeriod(facilityId, programId, programStartDate, startingPeriodId); assertThat(periods, is(periodList)); }
public List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId) { RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getAllPeriodsAfterDateAndPeriod(requisitionGroupProgramSchedule.getProcessingSchedule().getId(), startingPeriodId, programStartDate, new Date()); }
ProcessingScheduleService { public List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId) { RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getAllPeriodsAfterDateAndPeriod(requisitionGroupProgramSchedule.getProcessingSchedule().getId(), startingPeriodId, programStartDate, new Date()); } }
ProcessingScheduleService { public List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId) { RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getAllPeriodsAfterDateAndPeriod(requisitionGroupProgramSchedule.getProcessingSchedule().getId(), startingPeriodId, programStartDate, new Date()); } @Autowired  ProcessingScheduleService(ProcessingScheduleRepository scheduleRepository, ProcessingPeriodRepository periodRepository,
                                   RequisitionGroupRepository requisitionGroupRepository, RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository); }
ProcessingScheduleService { public List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId) { RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getAllPeriodsAfterDateAndPeriod(requisitionGroupProgramSchedule.getProcessingSchedule().getId(), startingPeriodId, programStartDate, new Date()); } @Autowired  ProcessingScheduleService(ProcessingScheduleRepository scheduleRepository, ProcessingPeriodRepository periodRepository,
                                   RequisitionGroupRepository requisitionGroupRepository, RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository); List<ProcessingSchedule> getAll(); ProcessingSchedule save(ProcessingSchedule processingSchedule); List<ProcessingPeriod> getAllPeriods(Long scheduleId); ProcessingSchedule get(Long id); void savePeriod(ProcessingPeriod processingPeriod); void deletePeriod(Long processingPeriodId); List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId); List<ProcessingPeriod> getOpenPeriods(Long facilityId, Long programId, Long startingPeriodId); ProcessingPeriod getPeriodById(Long periodId); List<ProcessingPeriod> getAllPeriodsForDateRange(Facility facility, Program program, Date startDate, Date endDate); List<ProcessingPeriod> getUsedPeriodsForDateRange(Facility facility, Program program, Date startDate, Date endDate); ProcessingSchedule getByCode(String code); List<ProcessingPeriod> getAllPeriodsBefore(Long scheduleId, Date beforeDate); ProcessingPeriod getPeriodForDate(Facility facility, Program program, Date date); ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate); List<ProcessingPeriod> getNPreviousPeriodsInDescOrder(ProcessingPeriod currentPeriod, Integer n); Integer findM(ProcessingPeriod period); List<ProcessingPeriod> getAllPeriodsForScheduleAndYear(Long scheduleId, Long year); }
ProcessingScheduleService { public List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId) { RequisitionGroupProgramSchedule requisitionGroupProgramSchedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getAllPeriodsAfterDateAndPeriod(requisitionGroupProgramSchedule.getProcessingSchedule().getId(), startingPeriodId, programStartDate, new Date()); } @Autowired  ProcessingScheduleService(ProcessingScheduleRepository scheduleRepository, ProcessingPeriodRepository periodRepository,
                                   RequisitionGroupRepository requisitionGroupRepository, RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository); List<ProcessingSchedule> getAll(); ProcessingSchedule save(ProcessingSchedule processingSchedule); List<ProcessingPeriod> getAllPeriods(Long scheduleId); ProcessingSchedule get(Long id); void savePeriod(ProcessingPeriod processingPeriod); void deletePeriod(Long processingPeriodId); List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long facilityId, Long programId, Date programStartDate, Long startingPeriodId); List<ProcessingPeriod> getOpenPeriods(Long facilityId, Long programId, Long startingPeriodId); ProcessingPeriod getPeriodById(Long periodId); List<ProcessingPeriod> getAllPeriodsForDateRange(Facility facility, Program program, Date startDate, Date endDate); List<ProcessingPeriod> getUsedPeriodsForDateRange(Facility facility, Program program, Date startDate, Date endDate); ProcessingSchedule getByCode(String code); List<ProcessingPeriod> getAllPeriodsBefore(Long scheduleId, Date beforeDate); ProcessingPeriod getPeriodForDate(Facility facility, Program program, Date date); ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate); List<ProcessingPeriod> getNPreviousPeriodsInDescOrder(ProcessingPeriod currentPeriod, Integer n); Integer findM(ProcessingPeriod period); List<ProcessingPeriod> getAllPeriodsForScheduleAndYear(Long scheduleId, Long year);  }