@Test public void shouldGetNumberOfMonthsFromPreviousPeriodOfCurrentPeriod() { ProcessingPeriod currentPeriod = new ProcessingPeriod(); List<ProcessingPeriod> previousPeriod = asList(make(a(defaultProcessingPeriod))); when(periodRepository.getNPreviousPeriods(currentPeriod, 1)).thenReturn(previousPeriod); Integer numberOfMonths = service.findM(currentPeriod); assertThat(numberOfMonths, is(1)); }
public Integer findM(ProcessingPeriod period) { List<ProcessingPeriod> nPreviousPeriods = periodRepository.getNPreviousPeriods(period, 1); if (nPreviousPeriods.size() > 0) { return nPreviousPeriods.get(0).getNumberOfMonths(); } return period.getNumberOfMonths(); }
ProcessingScheduleService { public Integer findM(ProcessingPeriod period) { List<ProcessingPeriod> nPreviousPeriods = periodRepository.getNPreviousPeriods(period, 1); if (nPreviousPeriods.size() > 0) { return nPreviousPeriods.get(0).getNumberOfMonths(); } return period.getNumberOfMonths(); } }
ProcessingScheduleService { public Integer findM(ProcessingPeriod period) { List<ProcessingPeriod> nPreviousPeriods = periodRepository.getNPreviousPeriods(period, 1); if (nPreviousPeriods.size() > 0) { return nPreviousPeriods.get(0).getNumberOfMonths(); } return period.getNumberOfMonths(); } @Autowired  ProcessingScheduleService(ProcessingScheduleRepository scheduleRepository, ProcessingPeriodRepository periodRepository,
                                   RequisitionGroupRepository requisitionGroupRepository, RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository); }
ProcessingScheduleService { public Integer findM(ProcessingPeriod period) { List<ProcessingPeriod> nPreviousPeriods = periodRepository.getNPreviousPeriods(period, 1); if (nPreviousPeriods.size() > 0) { return nPreviousPeriods.get(0).getNumberOfMonths(); } return period.getNumberOfMonths(); } @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 Integer findM(ProcessingPeriod period) { List<ProcessingPeriod> nPreviousPeriods = periodRepository.getNPreviousPeriods(period, 1); if (nPreviousPeriods.size() > 0) { return nPreviousPeriods.get(0).getNumberOfMonths(); } return period.getNumberOfMonths(); } @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);  }