@Test public void shouldNotInsertAPeriodWithSameNameForASchedule() throws Exception { ProcessingPeriod processingPeriod = mock(ProcessingPeriod.class); doNothing().when(processingPeriod).validate(); doThrow(DuplicateKeyException.class).when(mapper).insert(processingPeriod); exException.expect(dataExceptionMatcher("error.period.exist.for.schedule")); repository.insert(processingPeriod); }
public void insert(ProcessingPeriod processingPeriod) throws ParseException { processingPeriod.validate(); processingPeriod.includeEntireDuration(); try { validateStartDateGreaterThanLastPeriodEndDate(processingPeriod); mapper.insert(processingPeriod); } catch (DuplicateKeyException e) { throw new DataException("error.period.exist.for.schedule"); } }
ProcessingPeriodRepository { public void insert(ProcessingPeriod processingPeriod) throws ParseException { processingPeriod.validate(); processingPeriod.includeEntireDuration(); try { validateStartDateGreaterThanLastPeriodEndDate(processingPeriod); mapper.insert(processingPeriod); } catch (DuplicateKeyException e) { throw new DataException("error.period.exist.for.schedule"); } } }
ProcessingPeriodRepository { public void insert(ProcessingPeriod processingPeriod) throws ParseException { processingPeriod.validate(); processingPeriod.includeEntireDuration(); try { validateStartDateGreaterThanLastPeriodEndDate(processingPeriod); mapper.insert(processingPeriod); } catch (DuplicateKeyException e) { throw new DataException("error.period.exist.for.schedule"); } } @Autowired  ProcessingPeriodRepository(ProcessingPeriodMapper processingPeriodMapper); }
ProcessingPeriodRepository { public void insert(ProcessingPeriod processingPeriod) throws ParseException { processingPeriod.validate(); processingPeriod.includeEntireDuration(); try { validateStartDateGreaterThanLastPeriodEndDate(processingPeriod); mapper.insert(processingPeriod); } catch (DuplicateKeyException e) { throw new DataException("error.period.exist.for.schedule"); } } @Autowired  ProcessingPeriodRepository(ProcessingPeriodMapper processingPeriodMapper); List<ProcessingPeriod> getAll(Long scheduleId); void insert(ProcessingPeriod processingPeriod); void delete(Long processingPeriodId); List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long scheduleId, Long startPeriodId, Date afterDate, Date beforeDate); List<ProcessingPeriod> getOpenPeriods(Long facilityId, Long programId, Long startingPeriodId); ProcessingPeriod getById(Long id); List<ProcessingPeriod> getAllPeriodsForDateRange(Long scheduleId, Date startDate, Date endDate); List<ProcessingPeriod> getRnrPeriodsForDateRange(Long facilityId, Long programId, Date startDate, Date endDate); List<ProcessingPeriod> getAllPeriodsBefore(Long scheduleId, Date beforeDate); ProcessingPeriod getCurrentPeriod(Long scheduleId, Date programStartDate); List<ProcessingPeriod> getNPreviousPeriods(ProcessingPeriod currentPeriod, Integer n); ProcessingPeriod getPeriodForDate(Long scheduleId, Date date); List<ProcessingPeriod> getAllPeriodsForScheduleAndYear(Long scheduleId, Long year); }
ProcessingPeriodRepository { public void insert(ProcessingPeriod processingPeriod) throws ParseException { processingPeriod.validate(); processingPeriod.includeEntireDuration(); try { validateStartDateGreaterThanLastPeriodEndDate(processingPeriod); mapper.insert(processingPeriod); } catch (DuplicateKeyException e) { throw new DataException("error.period.exist.for.schedule"); } } @Autowired  ProcessingPeriodRepository(ProcessingPeriodMapper processingPeriodMapper); List<ProcessingPeriod> getAll(Long scheduleId); void insert(ProcessingPeriod processingPeriod); void delete(Long processingPeriodId); List<ProcessingPeriod> getAllPeriodsAfterDateAndPeriod(Long scheduleId, Long startPeriodId, Date afterDate, Date beforeDate); List<ProcessingPeriod> getOpenPeriods(Long facilityId, Long programId, Long startingPeriodId); ProcessingPeriod getById(Long id); List<ProcessingPeriod> getAllPeriodsForDateRange(Long scheduleId, Date startDate, Date endDate); List<ProcessingPeriod> getRnrPeriodsForDateRange(Long facilityId, Long programId, Date startDate, Date endDate); List<ProcessingPeriod> getAllPeriodsBefore(Long scheduleId, Date beforeDate); ProcessingPeriod getCurrentPeriod(Long scheduleId, Date programStartDate); List<ProcessingPeriod> getNPreviousPeriods(ProcessingPeriod currentPeriod, Integer n); ProcessingPeriod getPeriodForDate(Long scheduleId, Date date); List<ProcessingPeriod> getAllPeriodsForScheduleAndYear(Long scheduleId, Long year);  }