@Test(expected = IllegalArgumentException.class) public void convert_INCORRECT_RANGE() { MonthYearRange uixRange = new MonthYearRange(); uixRange.setStartMonth(11); uixRange.setStartYear(2010); uixRange.setEndMonth(10); uixRange.setEndYear(2010); monthYearRangeConverter.convert(uixRange); }
public XDateRange convert(MonthYearRange monthYearRange) { Preconditions.checkNotNull(monthYearRange); Preconditions.checkArgument((monthYearRange.getEndYear() - monthYearRange.getStartYear()) * 12 + monthYearRange.getEndMonth() - monthYearRange.getStartMonth() >= 0); LocalDate startDate = monthYearStartDateCalculator.calculateStartDate(monthYearRange.getStartYear(), monthYearRange.getStartMonth()); LocalDate endDate = monthYearEndDateCalculator.calculateEndDate(monthYearRange.getEndYear(), monthYearRange.getEndMonth()); Period gap = monthYearRangeGapCalculator.calculateGap(monthYearRange.getStartYear(), monthYearRange.getStartMonth(), monthYearRange.getEndYear(), monthYearRange.getEndMonth()); XDateRange xDateRange = new XDateRange(startDate, endDate, gap); return xDateRange; }
MonthYearRangeConverter { public XDateRange convert(MonthYearRange monthYearRange) { Preconditions.checkNotNull(monthYearRange); Preconditions.checkArgument((monthYearRange.getEndYear() - monthYearRange.getStartYear()) * 12 + monthYearRange.getEndMonth() - monthYearRange.getStartMonth() >= 0); LocalDate startDate = monthYearStartDateCalculator.calculateStartDate(monthYearRange.getStartYear(), monthYearRange.getStartMonth()); LocalDate endDate = monthYearEndDateCalculator.calculateEndDate(monthYearRange.getEndYear(), monthYearRange.getEndMonth()); Period gap = monthYearRangeGapCalculator.calculateGap(monthYearRange.getStartYear(), monthYearRange.getStartMonth(), monthYearRange.getEndYear(), monthYearRange.getEndMonth()); XDateRange xDateRange = new XDateRange(startDate, endDate, gap); return xDateRange; } }
MonthYearRangeConverter { public XDateRange convert(MonthYearRange monthYearRange) { Preconditions.checkNotNull(monthYearRange); Preconditions.checkArgument((monthYearRange.getEndYear() - monthYearRange.getStartYear()) * 12 + monthYearRange.getEndMonth() - monthYearRange.getStartMonth() >= 0); LocalDate startDate = monthYearStartDateCalculator.calculateStartDate(monthYearRange.getStartYear(), monthYearRange.getStartMonth()); LocalDate endDate = monthYearEndDateCalculator.calculateEndDate(monthYearRange.getEndYear(), monthYearRange.getEndMonth()); Period gap = monthYearRangeGapCalculator.calculateGap(monthYearRange.getStartYear(), monthYearRange.getStartMonth(), monthYearRange.getEndYear(), monthYearRange.getEndMonth()); XDateRange xDateRange = new XDateRange(startDate, endDate, gap); return xDateRange; }  }
MonthYearRangeConverter { public XDateRange convert(MonthYearRange monthYearRange) { Preconditions.checkNotNull(monthYearRange); Preconditions.checkArgument((monthYearRange.getEndYear() - monthYearRange.getStartYear()) * 12 + monthYearRange.getEndMonth() - monthYearRange.getStartMonth() >= 0); LocalDate startDate = monthYearStartDateCalculator.calculateStartDate(monthYearRange.getStartYear(), monthYearRange.getStartMonth()); LocalDate endDate = monthYearEndDateCalculator.calculateEndDate(monthYearRange.getEndYear(), monthYearRange.getEndMonth()); Period gap = monthYearRangeGapCalculator.calculateGap(monthYearRange.getStartYear(), monthYearRange.getStartMonth(), monthYearRange.getEndYear(), monthYearRange.getEndMonth()); XDateRange xDateRange = new XDateRange(startDate, endDate, gap); return xDateRange; }  XDateRange convert(MonthYearRange monthYearRange); @Autowired void setMonthYearRangeGapCalculator(MonthYearRangeGapCalculator monthYearRangeGapCalculator); @Autowired void setMonthYearStartDateCalculator(MonthYearStartDateCalculator monthYearStartDateCalculator); @Autowired void setMonthYearEndDateCalculator(MonthYearEndDateCalculator monthYearEndDateCalculator); }
MonthYearRangeConverter { public XDateRange convert(MonthYearRange monthYearRange) { Preconditions.checkNotNull(monthYearRange); Preconditions.checkArgument((monthYearRange.getEndYear() - monthYearRange.getStartYear()) * 12 + monthYearRange.getEndMonth() - monthYearRange.getStartMonth() >= 0); LocalDate startDate = monthYearStartDateCalculator.calculateStartDate(monthYearRange.getStartYear(), monthYearRange.getStartMonth()); LocalDate endDate = monthYearEndDateCalculator.calculateEndDate(monthYearRange.getEndYear(), monthYearRange.getEndMonth()); Period gap = monthYearRangeGapCalculator.calculateGap(monthYearRange.getStartYear(), monthYearRange.getStartMonth(), monthYearRange.getEndYear(), monthYearRange.getEndMonth()); XDateRange xDateRange = new XDateRange(startDate, endDate, gap); return xDateRange; }  XDateRange convert(MonthYearRange monthYearRange); @Autowired void setMonthYearRangeGapCalculator(MonthYearRangeGapCalculator monthYearRangeGapCalculator); @Autowired void setMonthYearStartDateCalculator(MonthYearStartDateCalculator monthYearStartDateCalculator); @Autowired void setMonthYearEndDateCalculator(MonthYearEndDateCalculator monthYearEndDateCalculator);  }