@Test public void convert() { MonthYearRange uixRange = new MonthYearRange(); uixRange.setStartMonth(1); uixRange.setStartYear(2010); uixRange.setEndMonth(10); uixRange.setEndYear(2015); LocalDate startDate = new LocalDate(uixRange.getStartYear(), uixRange.getStartMonth(), 1); when(monthYearStartDateCalculator.calculateStartDate(uixRange.getStartYear(), uixRange.getStartMonth())).thenReturn(startDate); LocalDate endDate = new LocalDate(uixRange.getEndYear(), uixRange.getEndMonth(), 30); when(monthYearEndDateCalculator.calculateEndDate(uixRange.getEndYear(), uixRange.getEndMonth())).thenReturn(endDate); Period gap = new Period(1, PeriodUnit.YEAR); when(monthYearRangeGapCalculator.calculateGap(uixRange.getStartYear(), uixRange.getStartMonth(), uixRange.getEndYear(), uixRange.getEndMonth())).thenReturn(gap); XDateRange xDateRange = monthYearRangeConverter.convert(uixRange); assertNotNull(xDateRange); assertEquals(startDate, xDateRange.getStartDate()); assertEquals(endDate, xDateRange.getEndDate()); assertEquals(gap, xDateRange.getGap()); }
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);  }