### Question:
MainChartXSettingsGenerator implements XSettingsGenerator { @Override public XSettings generateXSettings(JudgmentGlobalFilter judgmentGlobalFilter) { Preconditions.checkArgument(canGenerateXSettings(judgmentGlobalFilter)); XSettings xsettings = new XSettings(); xsettings.setRange(monthYearRangeConverter.convert(judgmentGlobalFilter.getJudgmentDateRange())); xsettings.setField(XField.JUDGMENT_DATE); return xsettings; }  @Override XSettings generateXSettings(JudgmentGlobalFilter judgmentGlobalFilter); @Override boolean canGenerateXSettings(JudgmentGlobalFilter judgmentGlobalFilter); @Override boolean handles(ChartCode chartCode); @Autowired void setMonthYearRangeConverter(MonthYearRangeConverter monthYearRangeConverter);  }### Answer:
@Test(expected = NullPointerException.class) public void generateXSettings_NULL() { xsettingsGenerator.generateXSettings(null); }
@Test(expected = IllegalArgumentException.class) public void generateXSettings_CannotGenerate() { xsettingsGenerator.generateXSettings(new JudgmentGlobalFilter()); }
@Test public void generateXSettings() { JudgmentGlobalFilter globalFilter = new JudgmentGlobalFilter(); MonthYearRange monthYearRange = new MonthYearRange(); globalFilter.setJudgmentDateRange(monthYearRange); XDateRange xDateRange = new XDateRange(new LocalDate(2000, 1, 1), new LocalDate(2011, 12, 31), new Period(2, PeriodUnit.MONTH)); when(monthYearRangeConverter.convert(monthYearRange)).thenReturn(xDateRange); XSettings xsettings = xsettingsGenerator.generateXSettings(globalFilter); assertNotNull(xsettings); assertEquals(xDateRange, xsettings.getRange()); assertEquals(XField.JUDGMENT_DATE, xsettings.getField()); }