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 java.io.StringReader; |
23 |
|
import java.util.HashMap; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import org.jmock.Expectations; |
27 |
|
import org.junit.Before; |
28 |
|
import org.xwiki.component.manager.ComponentManager; |
29 |
|
import org.xwiki.model.internal.DefaultModelConfiguration; |
30 |
|
import org.xwiki.model.internal.reference.DefaultEntityReferenceProvider; |
31 |
|
import org.xwiki.model.internal.reference.RelativeStringEntityReferenceResolver; |
32 |
|
import org.xwiki.rendering.block.XDOM; |
33 |
|
import org.xwiki.rendering.internal.macro.chart.source.DataSource; |
34 |
|
import org.xwiki.rendering.internal.parser.reference.DefaultUntypedLinkReferenceParser; |
35 |
|
import org.xwiki.rendering.internal.parser.reference.type.AttachmentResourceReferenceTypeParser; |
36 |
|
import org.xwiki.rendering.internal.parser.reference.type.DocumentResourceReferenceTypeParser; |
37 |
|
import org.xwiki.rendering.internal.parser.reference.type.SpaceResourceReferenceTypeParser; |
38 |
|
import org.xwiki.rendering.internal.parser.reference.type.URLResourceReferenceTypeParser; |
39 |
|
import org.xwiki.rendering.internal.parser.xwiki20.XWiki20ImageReferenceParser; |
40 |
|
import org.xwiki.rendering.internal.parser.xwiki20.XWiki20LinkReferenceParser; |
41 |
|
import org.xwiki.rendering.internal.parser.xwiki20.XWiki20Parser; |
42 |
|
import org.xwiki.rendering.internal.renderer.DefaultLinkLabelGenerator; |
43 |
|
import org.xwiki.rendering.internal.renderer.plain.PlainTextBlockRenderer; |
44 |
|
import org.xwiki.rendering.internal.renderer.plain.PlainTextRenderer; |
45 |
|
import org.xwiki.rendering.internal.renderer.plain.PlainTextRendererFactory; |
46 |
|
import org.xwiki.rendering.macro.MacroContentParser; |
47 |
|
import org.xwiki.rendering.parser.Parser; |
48 |
|
import org.xwiki.rendering.renderer.BlockRenderer; |
49 |
|
import org.xwiki.rendering.syntax.Syntax; |
50 |
|
import org.xwiki.test.annotation.ComponentList; |
51 |
|
import org.xwiki.test.jmock.AbstractMockingComponentTestCase; |
52 |
|
import org.xwiki.test.jmock.annotation.MockingRequirement; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@version |
58 |
|
@since |
59 |
|
|
60 |
|
|
61 |
|
@ComponentList({ |
62 |
|
PlainTextBlockRenderer.class, |
63 |
|
PlainTextRendererFactory.class, |
64 |
|
XWiki20Parser.class, |
65 |
|
XWiki20LinkReferenceParser.class, |
66 |
|
DefaultUntypedLinkReferenceParser.class, |
67 |
|
URLResourceReferenceTypeParser.class, |
68 |
|
XWiki20ImageReferenceParser.class, |
69 |
|
PlainTextRenderer.class, |
70 |
|
DefaultLinkLabelGenerator.class, |
71 |
|
DefaultEntityReferenceProvider.class, |
72 |
|
DefaultModelConfiguration.class, |
73 |
|
DocumentResourceReferenceTypeParser.class, |
74 |
|
SpaceResourceReferenceTypeParser.class, |
75 |
|
AttachmentResourceReferenceTypeParser.class, |
76 |
|
RelativeStringEntityReferenceResolver.class |
77 |
|
}) |
78 |
|
|
79 |
|
@MockingRequirement(value = MacroContentTableBlockDataSource.class, |
80 |
|
exceptions={ComponentManager.class, BlockRenderer.class}) |
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 6 |
Complexity Density: 0.55 |
|
81 |
|
public abstract class AbstractMacroContentTableBlockDataSourceTest extends AbstractMockingComponentTestCase |
82 |
|
{ |
83 |
|
private MacroContentTableBlockDataSource source; |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
9 |
@Before... |
86 |
|
public void configure() throws Exception |
87 |
|
{ |
88 |
9 |
this.source = getComponentManager().getInstance(DataSource.class, "inline"); |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
15 |
protected MacroContentTableBlockDataSource getDataSource()... |
92 |
|
{ |
93 |
15 |
return this.source; |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
96 |
6 |
protected Map<String, String> map(String... keyValues)... |
97 |
|
{ |
98 |
6 |
Map<String, String> map = new HashMap<String, String>(); |
99 |
|
|
100 |
29 |
for (int i = 0; i < keyValues.length; i += 2) { |
101 |
23 |
map.put(keyValues[i], keyValues[i + 1]); |
102 |
|
} |
103 |
|
|
104 |
6 |
return map; |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
107 |
7 |
protected void setUpContentExpectation(final String macroContent) throws Exception... |
108 |
|
{ |
109 |
7 |
final MacroContentParser parser = getComponentManager().getInstance(MacroContentParser.class); |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
7 |
final XDOM expectedXDOM = getComponentManager().<Parser>getInstance(Parser.class, |
114 |
|
Syntax.XWIKI_2_0.toIdString()).parse(new StringReader(macroContent)); |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
116 |
7 |
getMockery().checking(new Expectations() {{... |
117 |
|
|
118 |
7 |
oneOf(parser).parse(macroContent, null, true, false); |
119 |
7 |
will(returnValue(expectedXDOM)); |
120 |
|
}}); |
121 |
|
} |
122 |
|
} |