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.cache; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
|
24 |
|
import javax.inject.Provider; |
25 |
|
|
26 |
|
import org.junit.Before; |
27 |
|
import org.junit.Rule; |
28 |
|
import org.junit.Test; |
29 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWikiContext; |
32 |
|
import com.xpn.xwiki.web.XWikiURLFactory; |
33 |
|
|
34 |
|
import static org.junit.Assert.assertEquals; |
35 |
|
import static org.mockito.ArgumentMatchers.any; |
36 |
|
import static org.mockito.Mockito.mock; |
37 |
|
import static org.mockito.Mockito.when; |
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
42 |
|
public class XWikiContextCacheKeyFactoryTest |
43 |
|
{ |
44 |
|
@Rule |
45 |
|
public MockitoComponentMockingRule<XWikiContextCacheKeyFactory> mocker = |
46 |
|
new MockitoComponentMockingRule<>(XWikiContextCacheKeyFactory.class); |
47 |
|
|
48 |
|
private Provider<XWikiContext> xcontextProvider; |
49 |
|
|
50 |
|
private XWikiContext xcontext; |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
52 |
1 |
@Before... |
53 |
|
public void setUp() throws Exception |
54 |
|
{ |
55 |
1 |
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER); |
56 |
1 |
xcontext = mock(XWikiContext.class); |
57 |
1 |
when(xcontextProvider.get()).thenReturn(xcontext); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void getCacheKey() throws Exception |
62 |
|
{ |
63 |
|
|
64 |
1 |
XWikiURLFactory urlFactory = mock(XWikiURLFactory.class); |
65 |
1 |
when(xcontext.getURLFactory()).thenReturn(urlFactory); |
66 |
|
|
67 |
1 |
when(urlFactory.createSkinURL(any(), any(), any(XWikiContext.class))).thenReturn( |
68 |
|
new URL("http://host/path")); |
69 |
|
|
70 |
|
|
71 |
1 |
assertEquals("XWikiContext[URLFactory[" + urlFactory.getClass().getName() + ", /path]]", |
72 |
|
mocker.getComponentUnderTest().getCacheKey()); |
73 |
|
} |
74 |
|
} |