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

File DefaultWysiwygEditorConfigurationTest.java

 

Code metrics

0
12
2
1
80
46
2
0.17
6
2
1

Classes

Class Line # Actions
DefaultWysiwygEditorConfigurationTest 45 12 0% 2 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.wysiwyg.server.internal;
21   
22    import static org.junit.Assert.*;
23    import static org.mockito.Mockito.*;
24   
25    import org.junit.Before;
26    import org.junit.Rule;
27    import org.junit.Test;
28    import org.xwiki.bridge.DocumentAccessBridge;
29    import org.xwiki.context.Execution;
30    import org.xwiki.context.ExecutionContext;
31    import org.xwiki.model.EntityType;
32    import org.xwiki.model.ModelContext;
33    import org.xwiki.model.reference.DocumentReference;
34    import org.xwiki.model.reference.EntityReference;
35    import org.xwiki.test.mockito.MockitoComponentMockingRule;
36    import org.xwiki.wysiwyg.server.WysiwygEditorConfiguration;
37   
38    import com.xpn.xwiki.XWikiContext;
39   
40    /**
41    * Unit tests for {@link DefaultWysiwygEditorConfiguration}.
42    *
43    * @version $Id: 4ab9df3e161b02f80dd7b648af24f48860f9ffe1 $
44    */
 
45    public class DefaultWysiwygEditorConfigurationTest
46    {
47    @Rule
48    public MockitoComponentMockingRule<WysiwygEditorConfiguration> mocker =
49    new MockitoComponentMockingRule<WysiwygEditorConfiguration>(DefaultWysiwygEditorConfiguration.class);
50   
 
51  1 toggle @Before
52    public void configure() throws Exception
53    {
54  1 XWikiContext xcontext = mock(XWikiContext.class);
55  1 when(xcontext.getMainXWiki()).thenReturn("chess");
56   
57  1 ExecutionContext executionContext = mock(ExecutionContext.class);
58  1 when(executionContext.getProperty("xwikicontext")).thenReturn(xcontext);
59   
60  1 Execution execution = mocker.getInstance(Execution.class);
61  1 when(execution.getContext()).thenReturn(executionContext);
62    }
63   
 
64  1 toggle @Test
65    public void getPropertyWithFallBack() throws Exception
66    {
67  1 ModelContext modelContext = mocker.getInstance(ModelContext.class);
68  1 when(modelContext.getCurrentEntityReference()).thenReturn(new EntityReference("tennis", EntityType.WIKI));
69   
70  1 DocumentAccessBridge dab = mocker.getInstance(DocumentAccessBridge.class);
71  1 when(
72    dab.getProperty(new DocumentReference("tennis", "XWiki", "WysiwygEditorConfig"), new DocumentReference(
73    "tennis", "XWiki", "WysiwygEditorConfigClass"), "plugins")).thenReturn(null);
74  1 when(
75    dab.getProperty(new DocumentReference("chess", "XWiki", "WysiwygEditorConfig"), new DocumentReference(
76    "chess", "XWiki", "WysiwygEditorConfigClass"), "plugins")).thenReturn("foo bar");
77   
78  1 assertEquals("foo bar", mocker.getComponentUnderTest().getPlugins());
79    }
80    }