1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.xar.internal.repository; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.extension.ExtensionId; |
29 |
|
import org.xwiki.extension.ResolveException; |
30 |
|
import org.xwiki.extension.repository.InstalledExtensionRepository; |
31 |
|
import org.xwiki.extension.repository.search.SearchException; |
32 |
|
import org.xwiki.extension.test.MockitoRepositoryUtilsRule; |
33 |
|
import org.xwiki.model.reference.DocumentReference; |
34 |
|
import org.xwiki.test.annotation.AllComponents; |
35 |
|
import org.xwiki.test.mockito.MockitoComponentManagerRule; |
36 |
|
|
37 |
|
import static org.junit.Assert.assertEquals; |
38 |
|
import static org.junit.Assert.assertNotNull; |
39 |
|
import static org.junit.Assert.assertNull; |
40 |
|
|
41 |
|
@AllComponents |
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 2 |
Complexity Density: 0.12 |
|
42 |
|
public class XarInstalledExtensionRepositoryTest |
43 |
|
{ |
44 |
|
protected MockitoComponentManagerRule mocker = new MockitoComponentManagerRule(); |
45 |
|
|
46 |
|
@Rule |
47 |
|
public MockitoRepositoryUtilsRule repositoryUtil = new MockitoRepositoryUtilsRule(this.mocker); |
48 |
|
|
49 |
|
private XarInstalledExtensionRepository installedExtensionRepository; |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
1 |
@Before... |
52 |
|
public void setUp() throws Exception |
53 |
|
{ |
54 |
1 |
this.installedExtensionRepository = this.mocker.getInstance(InstalledExtensionRepository.class, "xar"); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void testInit() throws ResolveException, SearchException |
61 |
|
{ |
62 |
1 |
assertEquals(1, this.installedExtensionRepository.countExtensions()); |
63 |
|
|
64 |
1 |
XarInstalledExtension xarInstalledExtension = |
65 |
|
this.installedExtensionRepository.resolve(new ExtensionId("xarinstalledextension", "1.0")); |
66 |
1 |
assertNotNull(xarInstalledExtension); |
67 |
|
|
68 |
1 |
assertNotNull( |
69 |
|
this.installedExtensionRepository.getInstalledExtension(new ExtensionId("xarinstalledextension", "1.0"))); |
70 |
1 |
assertNotNull(this.installedExtensionRepository.getInstalledExtension("xarinstalledextension", null)); |
71 |
1 |
assertNull(this.installedExtensionRepository.getInstalledExtension("notexisting", null)); |
72 |
|
|
73 |
1 |
assertEquals(1, this.installedExtensionRepository.getInstalledExtensions().size()); |
74 |
1 |
assertEquals(1, this.installedExtensionRepository.getInstalledExtensions(null).size()); |
75 |
|
|
76 |
1 |
assertEquals(1, this.installedExtensionRepository.search("xarinstalledextension", 0, -1).getSize()); |
77 |
1 |
assertEquals(1, this.installedExtensionRepository.search(null, 0, -1).getSize()); |
78 |
1 |
assertEquals(1, this.installedExtensionRepository |
79 |
|
.searchInstalledExtensions("xarinstalledextension", null, 0, -1).getSize()); |
80 |
1 |
assertEquals(1, this.installedExtensionRepository.searchInstalledExtensions(null, null, 0, -1).getSize()); |
81 |
|
|
82 |
1 |
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository |
83 |
|
.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page"))); |
84 |
1 |
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository |
85 |
|
.getXarInstalledExtensions(new DocumentReference("wiki2", "space", "page"))); |
86 |
1 |
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository |
87 |
|
.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ROOT))); |
88 |
1 |
assertEquals(0, this.installedExtensionRepository |
89 |
|
.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ENGLISH)).size()); |
90 |
|
} |
91 |
|
} |