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; |
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 |
|
@link |
42 |
|
|
43 |
|
@version |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
45 |
|
public class DefaultWysiwygEditorConfigurationTest |
46 |
|
{ |
47 |
|
@Rule |
48 |
|
public MockitoComponentMockingRule<WysiwygEditorConfiguration> mocker = |
49 |
|
new MockitoComponentMockingRule<WysiwygEditorConfiguration>(DefaultWysiwygEditorConfiguration.class); |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
51 |
1 |
@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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
64 |
1 |
@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 |
|
} |