1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wysiwyg.server.internal.plugin.importer; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
25 |
|
import org.xwiki.model.reference.AttachmentReference; |
26 |
|
import org.xwiki.model.reference.DocumentReference; |
27 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
28 |
|
import org.xwiki.rendering.block.XDOM; |
29 |
|
import org.xwiki.rendering.listener.MetaData; |
30 |
|
import org.xwiki.rendering.renderer.BlockRenderer; |
31 |
|
import org.xwiki.rendering.syntax.Syntax; |
32 |
|
import org.xwiki.rendering.transformation.RenderingContext; |
33 |
|
import org.xwiki.rendering.transformation.Transformation; |
34 |
|
import org.xwiki.test.mockito.MockitoComponentManagerRule; |
35 |
|
|
36 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
37 |
|
|
38 |
|
import static org.mockito.Mockito.*; |
39 |
|
import static org.junit.Assert.*; |
40 |
|
|
41 |
|
|
42 |
|
@link |
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.08 |
|
47 |
|
public class OfficeMacroImporterTest |
48 |
|
{ |
49 |
|
@Rule |
50 |
|
public MockitoComponentManagerRule componentManager = new MockitoComponentManagerRule(); |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void buildXDOM() throws Exception |
54 |
|
{ |
55 |
1 |
componentManager.registerMockComponent(RenderingContext.class); |
56 |
1 |
componentManager.registerMockComponent(Transformation.class, "macro"); |
57 |
1 |
componentManager.registerMockComponent(BlockRenderer.class, "annotatedxhtml/1.0"); |
58 |
1 |
componentManager.registerMockComponent(EntityReferenceSerializer.TYPE_STRING); |
59 |
|
|
60 |
1 |
DocumentAccessBridge documentAccessBridge = componentManager.registerMockComponent(DocumentAccessBridge.class); |
61 |
1 |
DocumentReference documentReference = new DocumentReference("wiki", "space", "page"); |
62 |
1 |
XWikiDocument xwikiDocument = mock(XWikiDocument.class); |
63 |
1 |
when(documentAccessBridge.getDocument(documentReference)).thenReturn(xwikiDocument); |
64 |
1 |
when(xwikiDocument.getSyntax()).thenReturn(Syntax.XWIKI_2_1); |
65 |
|
|
66 |
1 |
OfficeMacroImporter importer = new OfficeMacroImporter(componentManager); |
67 |
1 |
XDOM xdom = importer.buildXDOM(new AttachmentReference("file", documentReference), true); |
68 |
|
|
69 |
1 |
assertNotNull(xdom); |
70 |
|
|
71 |
|
|
72 |
1 |
assertEquals("xwiki/2.1", ((Syntax) xdom.getMetaData().getMetaData(MetaData.SYNTAX)).toIdString()); |
73 |
|
} |
74 |
|
} |