@Test @SuppressWarnings("unchecked") public void exportChartToCsv() throws IOException { Writer writer = mock(Writer.class); doReturn(csvWriter).when(chartCsvExporter).createCsvWriter(writer); Series<Object, Number> series1 = new Series<>(); series1.addPoint("x1", 4); series1.addPoint("x2", 5); Series<Object, Number> series2 = mock(Series.class); Chart<Object, Number> chart = new Chart<>(Lists.newArrayList(series1, series2)); ChartCode chartCode = ChartCode.MAIN_CHART; AnalysisForm analysisForm = mock(AnalysisForm.class); Locale locale = Locale.FRANCE; String[] header = new String[]{"Y", "A", "B"}; String[] row1 = new String[]{"2012", "44", "55"}; String[] row2 = new String[]{"2013", "45", "56"}; when(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)).thenReturn(header); when(chartCsvGenerator.generateRow(chart, 0)).thenReturn(row1); when(chartCsvGenerator.generateRow(chart, 1)).thenReturn(row2); chartCsvExporter.exportChartToCsv(chart, chartCode, analysisForm, locale, writer); verify(csvWriter).writeNext(header); verify(csvWriter).writeNext(row1); verify(csvWriter).writeNext(row2); verify(csvWriter).close(); verifyNoMoreInteractions(csvWriter); }
public void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer) throws IOException { CSVWriter csvWriter = createCsvWriter(writer); try { csvWriter.writeNext(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)); int rowCount = chart.getSeriesList().get(0).getPoints().size(); for (int i=0; i<rowCount; ++i) { csvWriter.writeNext(chartCsvGenerator.generateRow(chart, i)); } } finally { csvWriter.close(); } }
ChartCsvExporter { public void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer) throws IOException { CSVWriter csvWriter = createCsvWriter(writer); try { csvWriter.writeNext(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)); int rowCount = chart.getSeriesList().get(0).getPoints().size(); for (int i=0; i<rowCount; ++i) { csvWriter.writeNext(chartCsvGenerator.generateRow(chart, i)); } } finally { csvWriter.close(); } } }
ChartCsvExporter { public void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer) throws IOException { CSVWriter csvWriter = createCsvWriter(writer); try { csvWriter.writeNext(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)); int rowCount = chart.getSeriesList().get(0).getPoints().size(); for (int i=0; i<rowCount; ++i) { csvWriter.writeNext(chartCsvGenerator.generateRow(chart, i)); } } finally { csvWriter.close(); } }  }
ChartCsvExporter { public void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer) throws IOException { CSVWriter csvWriter = createCsvWriter(writer); try { csvWriter.writeNext(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)); int rowCount = chart.getSeriesList().get(0).getPoints().size(); for (int i=0; i<rowCount; ++i) { csvWriter.writeNext(chartCsvGenerator.generateRow(chart, i)); } } finally { csvWriter.close(); } }  void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer); @Autowired void setChartCsvGenerator(ChartCsvGenerator chartCsvGenerator); }
ChartCsvExporter { public void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer) throws IOException { CSVWriter csvWriter = createCsvWriter(writer); try { csvWriter.writeNext(chartCsvGenerator.generateHeader(chartCode, analysisForm, locale)); int rowCount = chart.getSeriesList().get(0).getPoints().size(); for (int i=0; i<rowCount; ++i) { csvWriter.writeNext(chartCsvGenerator.generateRow(chart, i)); } } finally { csvWriter.close(); } }  void exportChartToCsv(Chart<Object, Number> chart, ChartCode chartCode, AnalysisForm analysisForm, Locale locale, Writer writer); @Autowired void setChartCsvGenerator(ChartCsvGenerator chartCsvGenerator);  }