@Test public void generateSeries() { JudgmentSeriesCriteria criteria = mock(JudgmentSeriesCriteria.class); XSettings xsettings = mock(XSettings.class); YSettings ysettings = mock(YSettings.class); when(ysettings.getValueType()).thenReturn(mock(YValueType.class)); Series<Object, Integer> series = new Series<>(); series.addPoint("X", 123); when(seriesGenerator.generateSeries(criteria, xsettings)).thenReturn(series); SeriesYRecalculator seriesYRecalculator = mock(SeriesYRecalculator.class); when(seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType())).thenReturn(seriesYRecalculator); Series<Object, Number> recalcSeries = new Series<>(); @SuppressWarnings("unchecked") Series<Object, Number> recalculateSeries = (Series<Object, Number>)seriesYRecalculator.recalculateSeries(series, criteria, xsettings, ysettings); when(recalculateSeries).thenReturn(recalcSeries); Series<Object, Number> generatedSeries = seriesService.generateSeries(criteria, xsettings, ysettings); assertTrue(recalcSeries == generatedSeries); verify(seriesGenerator).generateSeries(criteria, xsettings); verify(seriesYRecalculatorManager).getSeriesYRecalculator(ysettings.getValueType()); verify(seriesYRecalculator).recalculateSeries(series, criteria, xsettings, ysettings); }
@Override public Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings) { checkArguments(criteria, xsettings, ysettings); Series<Object, Integer> series = seriesGenerator.generateSeries(criteria, xsettings); @SuppressWarnings("unchecked") Series<Object, Number> recalcSeries = (Series<Object, Number>)seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType()).recalculateSeries(series, criteria, xsettings, ysettings); return recalcSeries; }
SolrSeriesService implements SeriesService { @Override public Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings) { checkArguments(criteria, xsettings, ysettings); Series<Object, Integer> series = seriesGenerator.generateSeries(criteria, xsettings); @SuppressWarnings("unchecked") Series<Object, Number> recalcSeries = (Series<Object, Number>)seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType()).recalculateSeries(series, criteria, xsettings, ysettings); return recalcSeries; } }
SolrSeriesService implements SeriesService { @Override public Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings) { checkArguments(criteria, xsettings, ysettings); Series<Object, Integer> series = seriesGenerator.generateSeries(criteria, xsettings); @SuppressWarnings("unchecked") Series<Object, Number> recalcSeries = (Series<Object, Number>)seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType()).recalculateSeries(series, criteria, xsettings, ysettings); return recalcSeries; }  }
SolrSeriesService implements SeriesService { @Override public Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings) { checkArguments(criteria, xsettings, ysettings); Series<Object, Integer> series = seriesGenerator.generateSeries(criteria, xsettings); @SuppressWarnings("unchecked") Series<Object, Number> recalcSeries = (Series<Object, Number>)seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType()).recalculateSeries(series, criteria, xsettings, ysettings); return recalcSeries; }  @Override Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings); @Autowired void setSeriesGenerator(SeriesGenerator seriesGenerator); @Autowired void setSeriesYRecalculatorManager(SeriesYRecalculatorManager seriesYRecalculatorManager); }
SolrSeriesService implements SeriesService { @Override public Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings) { checkArguments(criteria, xsettings, ysettings); Series<Object, Integer> series = seriesGenerator.generateSeries(criteria, xsettings); @SuppressWarnings("unchecked") Series<Object, Number> recalcSeries = (Series<Object, Number>)seriesYRecalculatorManager.getSeriesYRecalculator(ysettings.getValueType()).recalculateSeries(series, criteria, xsettings, ysettings); return recalcSeries; }  @Override Series<Object, Number> generateSeries(JudgmentSeriesCriteria criteria, XSettings xsettings, YSettings ysettings); @Autowired void setSeriesGenerator(SeriesGenerator seriesGenerator); @Autowired void setSeriesYRecalculatorManager(SeriesYRecalculatorManager seriesYRecalculatorManager);  }