1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.lesscss.internal.listeners; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.bridge.event.ActionExecutingEvent; |
25 |
|
import org.xwiki.lesscss.internal.LESSContext; |
26 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
27 |
|
|
28 |
|
import com.xpn.xwiki.XWikiContext; |
29 |
|
import com.xpn.xwiki.web.XWikiRequest; |
30 |
|
|
31 |
|
import static org.junit.Assert.assertEquals; |
32 |
|
import static org.mockito.Mockito.mock; |
33 |
|
import static org.mockito.Mockito.verify; |
34 |
|
import static org.mockito.Mockito.verifyZeroInteractions; |
35 |
|
import static org.mockito.Mockito.when; |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 4 |
Complexity Density: 0.24 |
|
43 |
|
public class LESSExportActionListenerTest |
44 |
|
{ |
45 |
|
@Rule |
46 |
|
public MockitoComponentMockingRule<LESSExportActionListener> mocker = |
47 |
|
new MockitoComponentMockingRule<>(LESSExportActionListener.class); |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void getName() throws Exception |
51 |
|
{ |
52 |
1 |
assertEquals("lessexport", this.mocker.getComponentUnderTest().getName()); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void getEvents() throws Exception |
57 |
|
{ |
58 |
1 |
assertEquals(1, this.mocker.getComponentUnderTest().getEvents().size()); |
59 |
1 |
assertEquals(new ActionExecutingEvent("export"), this.mocker.getComponentUnderTest().getEvents().get(0)); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void onEventWhenHTMLExport() throws Exception |
64 |
|
{ |
65 |
1 |
XWikiContext xcontext = mock(XWikiContext.class); |
66 |
1 |
XWikiRequest request = mock(XWikiRequest.class); |
67 |
1 |
when(xcontext.getRequest()).thenReturn(request); |
68 |
1 |
when(request.get("format")).thenReturn("html"); |
69 |
|
|
70 |
1 |
this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext); |
71 |
|
|
72 |
|
|
73 |
1 |
LESSContext lessContext = mocker.getInstance(LESSContext.class); |
74 |
1 |
verify(lessContext).setHtmlExport(true); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
public void onEventWhenNonHTMLExport() throws Exception |
79 |
|
{ |
80 |
1 |
XWikiContext xcontext = mock(XWikiContext.class); |
81 |
1 |
XWikiRequest request = mock(XWikiRequest.class); |
82 |
1 |
when(xcontext.getRequest()).thenReturn(request); |
83 |
1 |
when(request.get("format")).thenReturn("xar"); |
84 |
|
|
85 |
1 |
this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext); |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
1 |
LESSContext lessContext = mocker.getInstance(LESSContext.class); |
90 |
1 |
verifyZeroInteractions(lessContext); |
91 |
|
} |
92 |
|
} |