1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.macro.chart.source.table; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
|
25 |
|
import org.jfree.data.general.Dataset; |
26 |
|
import org.jfree.data.general.PieDataset; |
27 |
|
|
28 |
|
import org.xwiki.chart.model.ChartModel; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 2 |
Complexity Density: 0.08 |
|
36 |
|
public class TablePieDatasetBuilderTest extends AbstractMacroContentTableBlockDataSourceTest |
37 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
38 |
1 |
@Test... |
39 |
|
public void testBuildPieDataset() throws Exception |
40 |
|
{ |
41 |
1 |
String content = |
42 |
|
"| column 1 | column 2 | column 3 | column 4\n" + |
43 |
|
"| row 1 | 12 | 13 | 14 \n" + |
44 |
|
"| row 2 | 22 | 23 | 24 \n"; |
45 |
1 |
setUpContentExpectation(content); |
46 |
|
|
47 |
1 |
getDataSource().buildDataset(content, map("type", "pie", "range", "B2-D3"), null); |
48 |
|
|
49 |
1 |
ChartModel chartModel = getDataSource().getChartModel(); |
50 |
|
|
51 |
1 |
Dataset dataset = chartModel.getDataset(); |
52 |
|
|
53 |
1 |
Assert.assertTrue(dataset instanceof PieDataset); |
54 |
|
|
55 |
1 |
PieDataset pieDataset = (PieDataset) dataset; |
56 |
|
|
57 |
1 |
Assert.assertTrue(pieDataset.getKey(0).equals(" row 1 ")); |
58 |
1 |
Assert.assertTrue(pieDataset.getKey(1).equals(" row 2 ")); |
59 |
|
|
60 |
1 |
Assert.assertTrue(pieDataset.getValue(0).intValue() == 12); |
61 |
1 |
Assert.assertTrue(pieDataset.getValue(1).intValue() == 22); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void testBuildPieDatasetRowsSeries() throws Exception |
66 |
|
{ |
67 |
1 |
String content = |
68 |
|
"| column 1 | column 2 | column 3 | column 4\n" + |
69 |
|
"| row 1 | 12 | 13 | 14 \n" + |
70 |
|
"| row 2 | 22 | 23 | 24 \n"; |
71 |
1 |
setUpContentExpectation(content); |
72 |
|
|
73 |
1 |
getDataSource().buildDataset(content, map("type", "pie", "range", "B2-D3", "series", "rows"), null); |
74 |
|
|
75 |
1 |
ChartModel chartModel = getDataSource().getChartModel(); |
76 |
|
|
77 |
1 |
Dataset dataset = chartModel.getDataset(); |
78 |
|
|
79 |
1 |
Assert.assertTrue(dataset instanceof PieDataset); |
80 |
|
|
81 |
1 |
PieDataset pieDataset = (PieDataset) dataset; |
82 |
|
|
83 |
1 |
Assert.assertTrue(pieDataset.getKey(0).equals(" column 2 ")); |
84 |
1 |
Assert.assertTrue(pieDataset.getKey(1).equals(" column 3 ")); |
85 |
1 |
Assert.assertTrue(pieDataset.getKey(2).equals(" column 4")); |
86 |
|
|
87 |
1 |
Assert.assertTrue(pieDataset.getValue(0).intValue() == 12); |
88 |
1 |
Assert.assertTrue(pieDataset.getValue(1).intValue() == 13); |
89 |
1 |
Assert.assertTrue(pieDataset.getValue(2).intValue() == 14); |
90 |
|
} |
91 |
|
} |