use of org.xwiki.chart.model.ChartModel in project xwiki-platform by xwiki.
the class TablePieDatasetBuilderTest method testBuildPieDatasetRowsSeries.
@Test
public void testBuildPieDatasetRowsSeries() throws Exception {
String content = "| column 1 | column 2 | column 3 | column 4\n" + "| row 1 | 12 | 13 | 14 \n" + "| row 2 | 22 | 23 | 24 \n";
setUpContentExpectation(content);
getDataSource().buildDataset(content, map("type", "pie", "range", "B2-D3", "series", "rows"), null);
ChartModel chartModel = getDataSource().getChartModel();
Dataset dataset = chartModel.getDataset();
Assert.assertTrue(dataset instanceof PieDataset);
PieDataset pieDataset = (PieDataset) dataset;
Assert.assertTrue(pieDataset.getKey(0).equals(" column 2 "));
Assert.assertTrue(pieDataset.getKey(1).equals(" column 3 "));
Assert.assertTrue(pieDataset.getKey(2).equals(" column 4"));
Assert.assertTrue(pieDataset.getValue(0).intValue() == 12);
Assert.assertTrue(pieDataset.getValue(1).intValue() == 13);
Assert.assertTrue(pieDataset.getValue(2).intValue() == 14);
}
Aggregations