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.util.Collections; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
28 |
|
import org.xwiki.model.reference.DocumentReference; |
29 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
30 |
|
import org.xwiki.rendering.block.Block; |
31 |
|
import org.xwiki.rendering.block.MacroBlock; |
32 |
|
import org.xwiki.rendering.block.MetaDataBlock; |
33 |
|
import org.xwiki.rendering.block.match.BlockMatcher; |
34 |
|
import org.xwiki.rendering.listener.MetaData; |
35 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
36 |
|
|
37 |
|
import static org.mockito.Mockito.*; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
45 |
|
public class DocumentTableBlockDataSourceTest |
46 |
|
{ |
47 |
|
@Rule |
48 |
|
public MockitoComponentMockingRule<DocumentTableBlockDataSource> componentManager = |
49 |
|
new MockitoComponentMockingRule<DocumentTableBlockDataSource>(DocumentTableBlockDataSource.class); |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void isDefinedChartSourceTheCurrentDocumentWhenReferenceNotNullAndMatching() throws Exception |
53 |
|
{ |
54 |
1 |
DocumentAccessBridge dab = this.componentManager.getInstance(DocumentAccessBridge.class); |
55 |
1 |
DocumentReference currentReference = new DocumentReference("currentwiki", "currentspace", "currentpage"); |
56 |
1 |
when(dab.getCurrentDocumentReference()).thenReturn(currentReference); |
57 |
|
|
58 |
1 |
DocumentReferenceResolver<String> resolver = |
59 |
|
this.componentManager.getInstance(DocumentReferenceResolver.TYPE_STRING); |
60 |
1 |
DocumentReference documentReference = new DocumentReference("wiki", "space", "page"); |
61 |
1 |
when(resolver.resolve("wiki:space.page", currentReference)).thenReturn(documentReference); |
62 |
|
|
63 |
1 |
MacroBlock currentMacroBlock = mock(MacroBlock.class); |
64 |
1 |
MetaDataBlock metaDataBlock = new MetaDataBlock(Collections.EMPTY_LIST, |
65 |
|
new MetaData(Collections.singletonMap(MetaData.SOURCE, (Object) "wiki:space.page"))); |
66 |
1 |
when(currentMacroBlock.getFirstBlock(any(BlockMatcher.class), any(Block.Axes.class))).thenReturn(metaDataBlock); |
67 |
|
|
68 |
1 |
DocumentTableBlockDataSource source = this.componentManager.getComponentUnderTest(); |
69 |
1 |
source.setParameter("document", "wiki:space.page"); |
70 |
|
|
71 |
1 |
Assert.assertTrue(source.isDefinedChartSourceTheCurrentDocument(currentMacroBlock)); |
72 |
|
} |
73 |
|
} |