### Question:
FlotChartAggregator { public FlotChart aggregateChart(FlotChart chart, UiyValueType yValueType) { Preconditions.checkNotNull(chart); Preconditions.checkNotNull(yValueType); FlotChart aggregatedChart = new FlotChart(); int i = 0; for (FlotSeries flotSeries : chart.getSeriesList()) { FlotSeries aggregatedFlotSeries = flotSeriesAggregatorManager.aggregateFlotSeries(flotSeries, i++, yValueType); aggregatedChart.addSeries(aggregatedFlotSeries); } return aggregatedChart; }  FlotChart aggregateChart(FlotChart chart, UiyValueType yValueType); @Autowired void setFlotSeriesAggregatorManager(FlotSeriesAggregatorManager flotSeriesAggregatorManager);  }### Answer:
@Test(expected = NullPointerException.class) public void aggregateChart_NULL_chart() { chartAggregator.aggregateChart(null, UiyValueType.NUMBER); }
@Test(expected = NullPointerException.class) public void aggregateChart_NULL_yValueType() { chartAggregator.aggregateChart(mock(FlotChart.class), null); }
@Test public void aggregateChart() { FlotChart chart = mock(FlotChart.class); FlotSeries series1 = mock(FlotSeries.class); FlotSeries series2 = mock(FlotSeries.class); List<FlotSeries> seriesList = Lists.newArrayList(series1, series2); when(chart.getSeriesList()).thenReturn(seriesList); UiyValueType yValueType = UiyValueType.PERCENT; FlotSeries aggrSeries1 = mock(FlotSeries.class); FlotSeries aggrSeries2 = mock(FlotSeries.class); when(flotSeriesAggregatorManager.aggregateFlotSeries(series1, 0, yValueType)).thenReturn(aggrSeries1); when(flotSeriesAggregatorManager.aggregateFlotSeries(series2, 1, yValueType)).thenReturn(aggrSeries2); FlotChart aggrChart = chartAggregator.aggregateChart(chart, yValueType); assertNotNull(aggrChart); assertThat(aggrChart.getSeriesList(), Matchers.contains(aggrSeries1, aggrSeries2)); }