@Test public void convert() { String value = "2010-10-01T00:00:00Z"; XDateRange range = mock(XDateRange.class); Period period = new Period(1, PeriodUnit.MONTH); when(range.getGap()).thenReturn(period); LocalDate startDate = new LocalDate(2010, 10, 1); LocalDate endDate = new LocalDate(2010, 10, 30); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(range); when(xDateRangeUtils.generateEndDate(startDate, period)).thenReturn(endDate); assertEquals(new MonthPeriod(2010, 10, 2010, 10), converter.convert(value, xsettings)); }
@Override public MonthPeriod convert(String value, XSettings xsettings) { Preconditions.checkNotNull(value); Preconditions.checkNotNull(xsettings); LocalDate startDate = SearchDateTimeUtils.convertISOStringToDate(value); Period period = xdateRangeUtils.getDateRange(xsettings).getGap(); LocalDate endDate = xdateRangeUtils.generateEndDate(startDate, period); return new MonthPeriod(startDate.getYear(), startDate.getMonthOfYear(), endDate.getYear(), endDate.getMonthOfYear()); }
FacetMonthPeriodValueConverter implements FacetValueConverter { @Override public MonthPeriod convert(String value, XSettings xsettings) { Preconditions.checkNotNull(value); Preconditions.checkNotNull(xsettings); LocalDate startDate = SearchDateTimeUtils.convertISOStringToDate(value); Period period = xdateRangeUtils.getDateRange(xsettings).getGap(); LocalDate endDate = xdateRangeUtils.generateEndDate(startDate, period); return new MonthPeriod(startDate.getYear(), startDate.getMonthOfYear(), endDate.getYear(), endDate.getMonthOfYear()); } }
FacetMonthPeriodValueConverter implements FacetValueConverter { @Override public MonthPeriod convert(String value, XSettings xsettings) { Preconditions.checkNotNull(value); Preconditions.checkNotNull(xsettings); LocalDate startDate = SearchDateTimeUtils.convertISOStringToDate(value); Period period = xdateRangeUtils.getDateRange(xsettings).getGap(); LocalDate endDate = xdateRangeUtils.generateEndDate(startDate, period); return new MonthPeriod(startDate.getYear(), startDate.getMonthOfYear(), endDate.getYear(), endDate.getMonthOfYear()); }  }
FacetMonthPeriodValueConverter implements FacetValueConverter { @Override public MonthPeriod convert(String value, XSettings xsettings) { Preconditions.checkNotNull(value); Preconditions.checkNotNull(xsettings); LocalDate startDate = SearchDateTimeUtils.convertISOStringToDate(value); Period period = xdateRangeUtils.getDateRange(xsettings).getGap(); LocalDate endDate = xdateRangeUtils.generateEndDate(startDate, period); return new MonthPeriod(startDate.getYear(), startDate.getMonthOfYear(), endDate.getYear(), endDate.getMonthOfYear()); }  @Override MonthPeriod convert(String value, XSettings xsettings); @Override boolean handles(XSettings xsettings); @Autowired void setXdateRangeUtils(XDateRangeUtils xdateRangeUtils); }
FacetMonthPeriodValueConverter implements FacetValueConverter { @Override public MonthPeriod convert(String value, XSettings xsettings) { Preconditions.checkNotNull(value); Preconditions.checkNotNull(xsettings); LocalDate startDate = SearchDateTimeUtils.convertISOStringToDate(value); Period period = xdateRangeUtils.getDateRange(xsettings).getGap(); LocalDate endDate = xdateRangeUtils.generateEndDate(startDate, period); return new MonthPeriod(startDate.getYear(), startDate.getMonthOfYear(), endDate.getYear(), endDate.getMonthOfYear()); }  @Override MonthPeriod convert(String value, XSettings xsettings); @Override boolean handles(XSettings xsettings); @Autowired void setXdateRangeUtils(XDateRangeUtils xdateRangeUtils);  }