1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.commands; |
35 |
|
|
36 |
|
import static org.junit.Assert.fail; |
37 |
|
import static org.mockito.Mockito.*; |
38 |
|
|
39 |
|
import info.magnolia.context.Context; |
40 |
|
import info.magnolia.module.cache.CacheModule; |
41 |
|
import info.magnolia.module.cache.ContentCachingConfiguration; |
42 |
|
import info.magnolia.repository.RepositoryManager; |
43 |
|
import info.magnolia.test.ComponentsTestUtil; |
44 |
|
|
45 |
|
import java.util.HashMap; |
46 |
|
import java.util.Map; |
47 |
|
|
48 |
|
import org.junit.After; |
49 |
|
import org.junit.Before; |
50 |
|
import org.junit.Test; |
51 |
|
|
52 |
|
|
53 |
|
@link |
54 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.36 |
|
55 |
|
public class FlushFromCachesByUUIDCommandTest { |
56 |
|
|
57 |
|
CacheModule cacheModule; |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
59 |
1 |
@Before... |
60 |
|
public void setUp() { |
61 |
1 |
RepositoryManager repositoryManager = mock(RepositoryManager.class); |
62 |
1 |
cacheModule = mock(CacheModule.class); |
63 |
1 |
Map<String, ContentCachingConfiguration> configurationMap = new HashMap(); |
64 |
1 |
ContentCachingConfiguration cacheConfiguration = new ContentCachingConfiguration(cacheModule, repositoryManager); |
65 |
1 |
configurationMap.put("test", cacheConfiguration); |
66 |
|
|
67 |
1 |
when(cacheModule.getContentCaching()).thenReturn(configurationMap); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
1 |
@After... |
71 |
|
public void tearDown() { |
72 |
1 |
ComponentsTestUtil.clear(); |
73 |
|
} |
74 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void testNPExceptionIsNotThrownIfNeverCachePolicyIsUsed() throws Exception { |
77 |
|
|
78 |
1 |
FlushFromCachesByUUIDCommand flushFromCachesByUUIDCommand = new FlushFromCachesByUUIDCommand(cacheModule); |
79 |
|
|
80 |
|
|
81 |
1 |
try { |
82 |
1 |
flushFromCachesByUUIDCommand.execute(mock(Context.class)); |
83 |
|
} catch (NullPointerException e) { |
84 |
0 |
fail("NPE should not be thrown here."); |
85 |
|
} |
86 |
|
} |
87 |
|
} |