### Question:
SeriesResultConverter { public Series<Object, Integer> convert(QueryResponse response, XSettings xsettings) { Preconditions.checkNotNull(response); Preconditions.checkNotNull(xsettings); List<FacetCount> facetCounts = xFieldFacetExtractor.extractFacetCounts(response, xsettings.getField()); return facetToSeriesConverter.convert(facetCounts, xsettings); }  Series<Object, Integer> convert(QueryResponse response, XSettings xsettings); @Autowired void setxFieldFacetExtractor(XFieldFacetExtractor xFieldFacetExtractor); @Autowired void setFacetToSeriesConverter(FacetToSeriesConverter facetToSeriesConverter);  }### Answer:
@Test public void convertToSeries() { QueryResponse response = new QueryResponse(); List<FacetCount> facetCounts = Lists.newArrayList(new FacetCount("facetValue1", 3), new FacetCount("facetValue2", 4)); Series<Object, Integer> series = new Series<Object, Integer>(); XSettings xsettings = mock(XSettings.class); when(xsettings.getField()).thenReturn(XField.JUDGMENT_DATE); doReturn(facetCounts).when(xFieldFacetExtractor).extractFacetCounts(response, XField.JUDGMENT_DATE); doReturn(series).when(facetToSeriesConverter).convert(facetCounts, xsettings); Series<Object, Integer> retSeries = seriesResultsConverter.convert(response, xsettings); assertTrue(retSeries == series); verify(xFieldFacetExtractor).extractFacetCounts(response, XField.JUDGMENT_DATE); verify(facetToSeriesConverter).convert(facetCounts, xsettings); }
@Test(expected = NullPointerException.class) public void convertToSeries_NULL_RESPONSE() { seriesResultsConverter.convert(null, mock(XSettings.class)); }
@Test(expected = NullPointerException.class) public void convertToSeries_NULL_XSETTINGS() { seriesResultsConverter.convert(new QueryResponse(), null); }