### Question:
ChartUtils { public static JFreeChart getBarChart(String chartName) throws MarshalException, ValidationException, IOException, SQLException { BarChart chartConfig = null; chartConfig = getBarChartConfigByName(chartName); if (chartConfig == null) { throw new IllegalArgumentException("getBarChart: Invalid chart name."); } DefaultCategoryDataset baseDataSet = buildCategoryDataSet(chartConfig); JFreeChart barChart = createBarChart(chartConfig, baseDataSet); addSubTitles(chartConfig, barChart); String subLabelClass = chartConfig.getSubLabelClass(); if(subLabelClass != null) { addSubLabels(barChart, subLabelClass); } customizeSeries(barChart, chartConfig); return barChart; }  static JFreeChart getBarChart(String chartName); static void getBarChart(String chartName, OutputStream out); static void getBarChartPNG(String chartName, OutputStream out); static byte[] getBarChartAsPNGByteArray(String chartName); static BufferedImage getChartAsBufferedImage(String chartName); static BarChart getBarChartConfigByName(String chartName); static Iterator<BarChart> getChartCollectionIterator();  }### Answer:
@Test public void testGetBarChart() throws MarshalException, ValidationException, IOException, SQLException { JFreeChart barChart = ChartUtils.getBarChart("sample-bar-chart"); assertNotNull(barChart); assertEquals(2, barChart.getSubtitleCount()); }
@Test public void testGetChartAsFileOutputStream() throws FileNotFoundException, IOException, SQLException, ValidationException, MarshalException { final File tempFile = File.createTempFile("sample-bar-chart", "png"); OutputStream stream = new FileOutputStream(tempFile); ChartUtils.getBarChart("sample-bar-chart", stream); stream.close(); }