### Question:
SeriesYRecalculatorManager { public SeriesYRecalculator getSeriesYRecalculator(YValueType yValueType) { for (SeriesYRecalculator seriesYRecalculator : seriesYRecalculators) { if (seriesYRecalculator.handles(yValueType)) { return seriesYRecalculator; } } throw new IllegalArgumentException("no seriesYRecalculator handling " + yValueType.getClass().getName() + " can be found"); }  SeriesYRecalculator getSeriesYRecalculator(YValueType yValueType); @Autowired void setSeriesYRecalculators(List<SeriesYRecalculator> seriesYRecalculators);  }### Answer:
@Test public void getSeriesYRecalculator() { YValueType yValueType1 = mock(YValueType.class); YValueType yValueType2 = mock(YValueType.class); when(seriesYRecalculator1.handles(yValueType1)).thenReturn(true); when(seriesYRecalculator1.handles(yValueType2)).thenReturn(false); when(seriesYRecalculator2.handles(yValueType1)).thenReturn(false); when(seriesYRecalculator2.handles(yValueType2)).thenReturn(true); assertTrue(seriesYRecalculator1 == seriesYRecalculatorManager.getSeriesYRecalculator(yValueType1)); assertFalse(seriesYRecalculator1 == seriesYRecalculatorManager.getSeriesYRecalculator(yValueType2)); assertTrue(seriesYRecalculator2 == seriesYRecalculatorManager.getSeriesYRecalculator(yValueType2)); assertFalse(seriesYRecalculator2 == seriesYRecalculatorManager.getSeriesYRecalculator(yValueType1)); }
@Test(expected = IllegalArgumentException.class) public void getSeriesYRecalculator_NoRecalculatorForValueType() { YValueType yValueType1 = mock(YValueType.class); when(seriesYRecalculator1.handles(yValueType1)).thenReturn(false); when(seriesYRecalculator2.handles(yValueType1)).thenReturn(false); seriesYRecalculatorManager.getSeriesYRecalculator(yValueType1); }