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 org.junit.Before; |
23 |
|
import org.junit.Rule; |
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.lesscss.internal.colortheme.ColorThemeReference; |
26 |
|
import org.xwiki.lesscss.internal.skin.SkinReference; |
27 |
|
import org.xwiki.lesscss.resources.LESSResourceReference; |
28 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
29 |
|
|
30 |
|
import static org.junit.Assert.assertEquals; |
31 |
|
import static org.mockito.Mockito.mock; |
32 |
|
import static org.mockito.Mockito.when; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 3 |
Complexity Density: 0.19 |
|
34 |
|
public class CacheKeyFactoryTest |
35 |
|
{ |
36 |
|
@Rule |
37 |
|
public MockitoComponentMockingRule<CacheKeyFactory> mocker = |
38 |
|
new MockitoComponentMockingRule<>(CacheKeyFactory.class); |
39 |
|
|
40 |
|
private XWikiContextCacheKeyFactory xcontextCacheKeyFactory; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
2 |
@Before... |
43 |
|
public void setUp() throws Exception |
44 |
|
{ |
45 |
2 |
xcontextCacheKeyFactory = mocker.getInstance(XWikiContextCacheKeyFactory.class); |
46 |
|
} |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
48 |
1 |
@Test... |
49 |
|
public void getCacheKeyWithContext() throws Exception |
50 |
|
{ |
51 |
|
|
52 |
1 |
LESSResourceReference lessResource = mock(LESSResourceReference.class); |
53 |
1 |
SkinReference skin = mock(SkinReference.class); |
54 |
1 |
ColorThemeReference colorTheme = mock(ColorThemeReference.class); |
55 |
|
|
56 |
1 |
when(lessResource.serialize()).thenReturn("lessResource"); |
57 |
1 |
when(skin.serialize()).thenReturn("skin"); |
58 |
1 |
when(colorTheme.serialize()).thenReturn("colorTheme"); |
59 |
1 |
when(xcontextCacheKeyFactory.getCacheKey()).thenReturn("XWikiContext[Mock]"); |
60 |
|
|
61 |
|
|
62 |
1 |
assertEquals("12_lessResource_4_skin_10_colorTheme_18_XWikiContext[Mock]", |
63 |
|
mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, true)); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void getCacheKeyWithoutContext() throws Exception |
68 |
|
{ |
69 |
|
|
70 |
1 |
LESSResourceReference lessResource = mock(LESSResourceReference.class); |
71 |
1 |
SkinReference skin = mock(SkinReference.class); |
72 |
1 |
ColorThemeReference colorTheme = mock(ColorThemeReference.class); |
73 |
|
|
74 |
1 |
when(lessResource.serialize()).thenReturn("lessResource"); |
75 |
1 |
when(skin.serialize()).thenReturn("skin"); |
76 |
1 |
when(colorTheme.serialize()).thenReturn("colorTheme"); |
77 |
|
|
78 |
|
|
79 |
1 |
assertEquals("12_lessResource_4_skin_10_colorTheme", |
80 |
|
mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, false)); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
} |