@Test public void shouldGetCurrentPeriodForFacilityAndProgram() { ProcessingSchedule processingSchedule = new ProcessingSchedule(11L); RequisitionGroupProgramSchedule schedule = new RequisitionGroupProgramSchedule(); schedule.setProcessingSchedule(processingSchedule); RequisitionGroup requisitionGroup = new RequisitionGroup(); requisitionGroup.setId(5L); when(requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(new Program(2L), new Facility(1L))) .thenReturn(requisitionGroup); when(requisitionGroupProgramScheduleRepository.getScheduleForRequisitionGroupAndProgram(5L, 2L)).thenReturn(schedule); Date programStartDate = new Date(); service.getCurrentPeriod(1L, 2L, programStartDate); verify(periodRepository).getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); }
public ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate) { RequisitionGroupProgramSchedule schedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); }
ProcessingScheduleService { public ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate) { RequisitionGroupProgramSchedule schedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); } }
ProcessingScheduleService { public ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate) { RequisitionGroupProgramSchedule schedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); } @Autowired  ProcessingScheduleService(ProcessingScheduleRepository scheduleRepository, ProcessingPeriodRepository periodRepository,
                                   RequisitionGroupRepository requisitionGroupRepository, RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository); }
ProcessingScheduleService { public ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate) { RequisitionGroupProgramSchedule schedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); } @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 ProcessingPeriod getCurrentPeriod(Long facilityId, Long programId, Date programStartDate) { RequisitionGroupProgramSchedule schedule = getSchedule(new Facility(facilityId), new Program(programId)); return periodRepository.getCurrentPeriod(schedule.getProcessingSchedule().getId(), programStartDate); } @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);  }