@Test public void generateChart() { JudgmentSeriesFilter filter1 = new JudgmentSeriesFilter(); filter1.setPhrase("ABC"); JudgmentSeriesFilter filter2 = new JudgmentSeriesFilter(); filter1.setPhrase("DEF"); List<JudgmentSeriesFilter> filters = Lists.newArrayList(filter1, filter2); JudgmentGlobalFilter globalFilter = mock(JudgmentGlobalFilter.class); UiySettings uiYSettings = new UiySettings(); AnalysisForm analysisForm = createAnalysisForm(globalFilter, filters, uiYSettings); JudgmentSeriesCriteria criteria1 = new JudgmentSeriesCriteria(); criteria1.setPhrase("ABC"); JudgmentSeriesCriteria criteria2 = new JudgmentSeriesCriteria(); criteria2.setPhrase("DEF"); List<JudgmentSeriesCriteria> criteriaList = Lists.newArrayList(criteria1, criteria2); XSettings xsettings = new XSettings(); YSettings ysettings = new YSettings(); Chart<Object, Number> chart = createChart(); ChartCode chartCode = ChartCode.MAIN_CHART; XSettingsGenerator xsettingsGenerator = mock(XSettingsGenerator.class); when(judgmentSeriesFilterConverter.convertList(globalFilter, filters)).thenReturn(criteriaList); when(xsettingsGeneratorManager.getXSettingsGenerator(chartCode)).thenReturn(xsettingsGenerator); when(xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter())).thenReturn(xsettings); when(xsettingsGenerator.canGenerateXSettings(analysisForm.getGlobalFilter())).thenReturn(true); when(uiySettingsConverter.convert(uiYSettings)).thenReturn(ysettings); when(analysisService.generateChart(criteriaList, xsettings, ysettings)).thenReturn(chart); Chart<Object, Number> generatedChart = chartGenerator.generateChart(chartCode, analysisForm); assertTrue(chart == generatedChart); verify(judgmentSeriesFilterConverter).convertList(globalFilter, filters); verify(xsettingsGeneratorManager, times(2)).getXSettingsGenerator(chartCode); verify(xsettingsGenerator).generateXSettings(globalFilter); verify(xsettingsGenerator).canGenerateXSettings(globalFilter); verify(uiySettingsConverter).convert(uiYSettings); verify(analysisService).generateChart(criteriaList, xsettings, ysettings); }
public Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm) { Preconditions.checkNotNull(analysisForm); Preconditions.checkArgument(canGenerateChart(chartCode, analysisForm)); XSettingsGenerator xsettingsGenerator = xsettingsGeneratorManager.getXSettingsGenerator(chartCode); XSettings xsettings = xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter()); YSettings ysettings = uiySettingsConverter.convert(analysisForm.getYsettings()); List<JudgmentSeriesCriteria> judgmentSeriesCriteriaList = judgmentSeriesFilterConverter.convertList(analysisForm.getGlobalFilter(), analysisForm.getSeriesFilters()); Chart<Object, Number> chart = chartService.generateChart(judgmentSeriesCriteriaList, xsettings, ysettings); return chart; }
ChartGenerator { public Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm) { Preconditions.checkNotNull(analysisForm); Preconditions.checkArgument(canGenerateChart(chartCode, analysisForm)); XSettingsGenerator xsettingsGenerator = xsettingsGeneratorManager.getXSettingsGenerator(chartCode); XSettings xsettings = xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter()); YSettings ysettings = uiySettingsConverter.convert(analysisForm.getYsettings()); List<JudgmentSeriesCriteria> judgmentSeriesCriteriaList = judgmentSeriesFilterConverter.convertList(analysisForm.getGlobalFilter(), analysisForm.getSeriesFilters()); Chart<Object, Number> chart = chartService.generateChart(judgmentSeriesCriteriaList, xsettings, ysettings); return chart; } }
ChartGenerator { public Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm) { Preconditions.checkNotNull(analysisForm); Preconditions.checkArgument(canGenerateChart(chartCode, analysisForm)); XSettingsGenerator xsettingsGenerator = xsettingsGeneratorManager.getXSettingsGenerator(chartCode); XSettings xsettings = xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter()); YSettings ysettings = uiySettingsConverter.convert(analysisForm.getYsettings()); List<JudgmentSeriesCriteria> judgmentSeriesCriteriaList = judgmentSeriesFilterConverter.convertList(analysisForm.getGlobalFilter(), analysisForm.getSeriesFilters()); Chart<Object, Number> chart = chartService.generateChart(judgmentSeriesCriteriaList, xsettings, ysettings); return chart; }  }
ChartGenerator { public Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm) { Preconditions.checkNotNull(analysisForm); Preconditions.checkArgument(canGenerateChart(chartCode, analysisForm)); XSettingsGenerator xsettingsGenerator = xsettingsGeneratorManager.getXSettingsGenerator(chartCode); XSettings xsettings = xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter()); YSettings ysettings = uiySettingsConverter.convert(analysisForm.getYsettings()); List<JudgmentSeriesCriteria> judgmentSeriesCriteriaList = judgmentSeriesFilterConverter.convertList(analysisForm.getGlobalFilter(), analysisForm.getSeriesFilters()); Chart<Object, Number> chart = chartService.generateChart(judgmentSeriesCriteriaList, xsettings, ysettings); return chart; }  Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm); boolean canGenerateChart(ChartCode chartCode, AnalysisForm analysisForm); @Autowired void setChartService(ChartService chartService); @Autowired void setJudgmentSeriesFilterConverter(JudgmentSeriesFilterConverter judgmentSeriesFilterConverter); @Autowired void setUiySettingsConverter(UiySettingsConverter uiySettingsConverter); @Autowired void setXsettingGeneratorManager(XSettingsGeneratorManager xsettingsGeneratorManager); }
ChartGenerator { public Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm) { Preconditions.checkNotNull(analysisForm); Preconditions.checkArgument(canGenerateChart(chartCode, analysisForm)); XSettingsGenerator xsettingsGenerator = xsettingsGeneratorManager.getXSettingsGenerator(chartCode); XSettings xsettings = xsettingsGenerator.generateXSettings(analysisForm.getGlobalFilter()); YSettings ysettings = uiySettingsConverter.convert(analysisForm.getYsettings()); List<JudgmentSeriesCriteria> judgmentSeriesCriteriaList = judgmentSeriesFilterConverter.convertList(analysisForm.getGlobalFilter(), analysisForm.getSeriesFilters()); Chart<Object, Number> chart = chartService.generateChart(judgmentSeriesCriteriaList, xsettings, ysettings); return chart; }  Chart<Object, Number> generateChart(ChartCode chartCode, AnalysisForm analysisForm); boolean canGenerateChart(ChartCode chartCode, AnalysisForm analysisForm); @Autowired void setChartService(ChartService chartService); @Autowired void setJudgmentSeriesFilterConverter(JudgmentSeriesFilterConverter judgmentSeriesFilterConverter); @Autowired void setUiySettingsConverter(UiySettingsConverter uiySettingsConverter); @Autowired void setXsettingGeneratorManager(XSettingsGeneratorManager xsettingsGeneratorManager);  }