1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.macro.context

File IntegrationTests.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
1
1
71
34
1
0.11
9
1
1

Classes

Class Line # Actions
IntegrationTests 48 9 0% 1 0
1.0100%
 

Contributing tests

No tests hitting this source file were found.

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.rendering.macro.context;
21   
22    import java.io.StringReader;
23   
24    import org.junit.runner.RunWith;
25    import org.xwiki.bridge.DocumentAccessBridge;
26    import org.xwiki.bridge.DocumentModelBridge;
27    import org.xwiki.component.util.DefaultParameterizedType;
28    import org.xwiki.model.reference.DocumentReference;
29    import org.xwiki.model.reference.DocumentReferenceResolver;
30    import org.xwiki.rendering.block.MacroBlock;
31    import org.xwiki.rendering.block.XDOM;
32    import org.xwiki.rendering.parser.Parser;
33    import org.xwiki.rendering.test.integration.RenderingTestSuite;
34    import org.xwiki.test.annotation.AllComponents;
35    import org.xwiki.test.mockito.MockitoComponentManager;
36   
37    import static org.mockito.Mockito.*;
38   
39    /**
40    * Run all tests found in {@code *.test} files located in the classpath. These {@code *.test} files must follow the
41    * conventions described in {@link org.xwiki.rendering.test.integration.TestDataParser}.
42    *
43    * @version $Id: ddcdb26053af122f61743e7af20191095169b6d5 $
44    * @since 8.3RC1
45    */
46    @RunWith(RenderingTestSuite.class)
47    @AllComponents
 
48    public class IntegrationTests
49    {
 
50  1 toggle @RenderingTestSuite.Initialized
51    public void initialize(MockitoComponentManager componentManager) throws Exception
52    {
53    // For performance reasons we mock some components to avoid having to draw all oldcore components
54   
55    // Macro Reference Resolver
56  1 DocumentReferenceResolver<String> macroResolver = componentManager.registerMockComponent(
57    new DefaultParameterizedType(null, DocumentReferenceResolver.class, String.class), "macro");
58  1 DocumentReference referencedDocumentReference = new DocumentReference("Wiki", "Space", "Page");
59  1 when(macroResolver.resolve(eq("Space.Page"), any(MacroBlock.class))).thenReturn(referencedDocumentReference);
60   
61    // Document Access Bridge mock
62    // Simulate the XDOM of the referenced document
63  1 DocumentAccessBridge dab = componentManager.registerMockComponent(DocumentAccessBridge.class);
64  1 DocumentModelBridge dmb = mock(DocumentModelBridge.class);
65  1 when(dab.getDocument(referencedDocumentReference)).thenReturn(dmb);
66   
67  1 Parser parser = componentManager.getInstance(Parser.class, "xwiki/2.1");
68  1 XDOM xdom = parser.parse(new StringReader("= heading1 =\n==heading2=="));
69  1 when(dmb.getXDOM()).thenReturn(xdom);
70    }
71    }