### Question:
FacetDayPeriodValueConverter implements FacetValueConverter { @Override public boolean handles(XSettings xsettings) { Preconditions.checkNotNull(xsettings); XDateRange range = xdateRangeUtils.getDateRange(xsettings); if (range != null && ( (range.getGap().getUnit().equals(DAY)) || (range.getGap().getUnit().equals(MONTH) && range.getStartDate().getDayOfMonth() != 1) || (range.getGap().getUnit().equals(YEAR) && range.getStartDate().getDayOfMonth() != 1))) { return true; } return false; }  @Override DayPeriod convert(String value, XSettings xsettings); @Override boolean handles(XSettings xsettings); @Autowired void setXdateRangeUtils(XDateRangeUtils xdateRangeUtils);  }### Answer:
@Test(expected = NullPointerException.class) public void handles_Null() { converter.handles(null); }
@Test public void handles_FALSE_NULL_DATE_RANGE() { when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(null); assertFalse(converter.handles(xsettings)); }
@Test public void handles_TRUE_DAY() { XDateRange dateRange = new XDateRange(new LocalDate(2011, 11, 11), new LocalDate(2011, 12, 12), new Period(3, PeriodUnit.DAY)); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(dateRange); assertTrue(converter.handles(xsettings)); }
@Test public void handles_TRUE_MONTH() { XDateRange dateRange = new XDateRange(new LocalDate(2011, 11, 11), new LocalDate(2011, 12, 12), new Period(3, PeriodUnit.MONTH)); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(dateRange); assertTrue(converter.handles(xsettings)); }
@Test public void handles_TRUE_YEAR() { XDateRange dateRange = new XDateRange(new LocalDate(2011, 11, 11), new LocalDate(2015, 12, 12), new Period(3, PeriodUnit.YEAR)); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(dateRange); assertTrue(converter.handles(xsettings)); }
@Test public void handles_FALSE_MONTH() { XDateRange dateRange = new XDateRange(new LocalDate(2011, 11, 1), new LocalDate(2012, 12, 12), new Period(3, PeriodUnit.MONTH)); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(dateRange); assertFalse(converter.handles(xsettings)); }
@Test public void handles_FALSE_YEAR() { XDateRange dateRange = new XDateRange(new LocalDate(2011, 1, 1), new LocalDate(2012, 12, 12), new Period(1, PeriodUnit.YEAR)); when(xDateRangeUtils.getDateRange(xsettings)).thenReturn(dateRange); assertFalse(converter.handles(xsettings)); }