### Question:
ChartConverter { public FlotChart convert(Chart<?, Number> chart) { Preconditions.checkNotNull(chart); FlotChart flotChart = new FlotChart(); for (Series<?, Number> series : chart.getSeriesList()) { flotChart.addSeries(flotSeriesConverter.convert(series)); } flotChart.setXticks(flotXticksGenerator.generateXticks(chart)); return flotChart; }  FlotChart convert(Chart<?, Number> chart); @Autowired void setSeriesConverter(SeriesConverter flotSeriesConverter); @Autowired void setFlotXticksGenerator(FlotXticksGenerator flotXticksGenerator);  }### Answer:
@Test(expected = NullPointerException.class) public void convert_Null() { chartConverter.convert(null); }
@Test public void convert() { Chart<Object, Number> chart = createChart(); FlotSeries flotSeries1 = mock(FlotSeries.class); FlotSeries flotSeries2 = mock(FlotSeries.class); List<Object[]> xticks = Lists.newArrayList(); when(seriesConverter.convert(chart.getSeriesList().get(0))).thenReturn(flotSeries1); when(seriesConverter.convert(chart.getSeriesList().get(1))).thenReturn(flotSeries2); when(flotXticksGenerator.generateXticks(chart)).thenReturn(xticks); FlotChart flotChart = chartConverter.convert(chart); assertNotNull(flotChart); assertEquals(2, flotChart.getSeriesList().size()); assertTrue(flotSeries1 == flotChart.getSeriesList().get(0)); assertTrue(flotSeries2 == flotChart.getSeriesList().get(1)); assertTrue(xticks == flotChart.getXticks()); }