### Question:
XSettingsGeneratorManager { public XSettingsGenerator getXSettingsGenerator(ChartCode chartCode) { Preconditions.checkNotNull(chartCode); for (XSettingsGenerator xsettingsGenerator : xsettingsGenerators) { if (xsettingsGenerator.handles(chartCode)) { return xsettingsGenerator; } } throw new IllegalArgumentException("no " + XSettingsGenerator.class.getName() + " handling " + chartCode.name() + " found"); }  XSettingsGenerator getXSettingsGenerator(ChartCode chartCode); @Autowired void setXsettingsGenerators(List<XSettingsGenerator> xsettingsGenerators);  }### Answer:
@Test(expected = NullPointerException.class) public void getXSettingsGenerator_NULL() { xsettingsGeneratorManager.getXSettingsGenerator(null); }
@Test(expected = IllegalArgumentException.class) public void getXSettingsGenerator_NoGeneratorsSet() { xsettingsGeneratorManager.getXSettingsGenerator(ChartCode.MAIN_CHART); }
@Test public void getXSettingsGenerator() { XSettingsGenerator xsettingsGenerator1 = mock(XSettingsGenerator.class); when(xsettingsGenerator1.handles(Mockito.any(ChartCode.class))).thenReturn(false); XSettingsGenerator xsettingsGenerator2 = mock(XSettingsGenerator.class); when(xsettingsGenerator2.handles(ChartCode.MAIN_CHART)).thenReturn(true); xsettingsGeneratorManager.setXsettingsGenerators(Lists.newArrayList(xsettingsGenerator1, xsettingsGenerator2)); assertTrue(xsettingsGenerator2 == xsettingsGeneratorManager.getXSettingsGenerator(ChartCode.MAIN_CHART)); }