1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.wysiwyg.server.internal.plugin.importer

File OfficeMacroImporterTest.java

 

Code metrics

0
13
1
1
74
39
1
0.08
13
1
1

Classes

Class Line # Actions
OfficeMacroImporterTest 47 13 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Unit tests for {@link org.xwiki.wysiwyg.server.internal.plugin.importer.OfficeMacroImporter}.
43    *
44    * @version $Id: c19cb0debc2920b5dc2d7c05915d93a6a856e3c0 $
45    * @since 6.2M1
46    */
 
47    public class OfficeMacroImporterTest
48    {
49    @Rule
50    public MockitoComponentManagerRule componentManager = new MockitoComponentManagerRule();
51   
 
52  1 toggle @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    // Verify we have the proper METADATA set
72  1 assertEquals("xwiki/2.1", ((Syntax) xdom.getMetaData().getMetaData(MetaData.SYNTAX)).toIdString());
73    }
74    }