1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.repository.installed; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.Date; |
25 |
|
import java.util.HashSet; |
26 |
|
|
27 |
|
import org.junit.Assert; |
28 |
|
import org.junit.Before; |
29 |
|
import org.junit.Test; |
30 |
|
import org.xwiki.extension.ExtensionId; |
31 |
|
import org.xwiki.extension.repository.internal.installed.DefaultInstalledExtension; |
32 |
|
import org.xwiki.extension.repository.internal.local.DefaultLocalExtension; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (73) |
Complexity: 6 |
Complexity Density: 0.09 |
|
34 |
|
public class DefaultInstalledExtensionTest |
35 |
|
{ |
36 |
|
private DefaultInstalledExtension installedExtension; |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
38 |
5 |
@Before... |
39 |
|
public void setUp() |
40 |
|
{ |
41 |
5 |
DefaultLocalExtension localExtension = |
42 |
|
new DefaultLocalExtension(null, new ExtensionId("installed", "version"), "type"); |
43 |
5 |
this.installedExtension = new DefaultInstalledExtension(localExtension, null); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void testIsInstalled() |
48 |
|
{ |
49 |
1 |
Assert.assertFalse(this.installedExtension.isInstalled()); |
50 |
1 |
Assert.assertFalse(this.installedExtension.isInstalled("namespace")); |
51 |
|
|
52 |
1 |
this.installedExtension.setInstalled(true); |
53 |
|
|
54 |
1 |
Assert.assertTrue(this.installedExtension.isInstalled()); |
55 |
1 |
Assert.assertTrue(this.installedExtension.isInstalled("namespace")); |
56 |
|
|
57 |
1 |
this.installedExtension.setInstalled(true, "namespace"); |
58 |
|
|
59 |
1 |
Assert.assertTrue(this.installedExtension.isInstalled()); |
60 |
1 |
Assert.assertTrue(this.installedExtension.isInstalled("namespace")); |
61 |
|
|
62 |
1 |
this.installedExtension.setInstalled(false); |
63 |
|
|
64 |
1 |
Assert.assertFalse(this.installedExtension.isInstalled()); |
65 |
1 |
Assert.assertFalse(this.installedExtension.isInstalled("namespace")); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
68 |
1 |
@Test... |
69 |
|
public void testIsValid() |
70 |
|
{ |
71 |
1 |
Assert.assertTrue(this.installedExtension.isValid(null)); |
72 |
1 |
Assert.assertTrue(this.installedExtension.isValid("namespace")); |
73 |
|
|
74 |
1 |
this.installedExtension.setValid(null, false); |
75 |
|
|
76 |
1 |
Assert.assertFalse(this.installedExtension.isValid(null)); |
77 |
1 |
Assert.assertTrue(this.installedExtension.isValid("namespace")); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
80 |
1 |
@Test... |
81 |
|
public void testIsDependency() |
82 |
|
{ |
83 |
1 |
Assert.assertFalse(this.installedExtension.isDependency()); |
84 |
1 |
Assert.assertFalse(this.installedExtension.isDependency("namespace")); |
85 |
|
|
86 |
1 |
this.installedExtension.setInstalled(true); |
87 |
|
|
88 |
1 |
Assert.assertFalse(this.installedExtension.isDependency()); |
89 |
1 |
Assert.assertFalse(this.installedExtension.isDependency("namespace")); |
90 |
|
|
91 |
1 |
this.installedExtension.setDependency(true, null); |
92 |
|
|
93 |
1 |
Assert.assertTrue(this.installedExtension.isDependency()); |
94 |
1 |
Assert.assertTrue(this.installedExtension.isDependency("namespace")); |
95 |
|
|
96 |
1 |
this.installedExtension.setInstalled(true, "namespace"); |
97 |
|
|
98 |
1 |
Assert.assertFalse(this.installedExtension.isDependency("namespace")); |
99 |
|
|
100 |
1 |
this.installedExtension.setDependency(true, "namespace"); |
101 |
|
|
102 |
1 |
Assert.assertTrue(this.installedExtension.isDependency("namespace")); |
103 |
|
|
104 |
1 |
this.installedExtension.setDependency(false, "namespace"); |
105 |
|
|
106 |
1 |
Assert.assertFalse(this.installedExtension.isDependency("namespace")); |
107 |
|
|
108 |
1 |
this.installedExtension.setDependency(false, null); |
109 |
1 |
this.installedExtension.setDependency(true, "namespace"); |
110 |
|
|
111 |
1 |
Assert.assertTrue(this.installedExtension.isDependency("namespace")); |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
114 |
1 |
@Test... |
115 |
|
public void testGetNamespaces() |
116 |
|
{ |
117 |
1 |
Assert.assertEquals(null, this.installedExtension.getNamespaces()); |
118 |
|
|
119 |
1 |
this.installedExtension.setInstalled(true, "namespace1"); |
120 |
|
|
121 |
1 |
Assert |
122 |
|
.assertEquals(Arrays.asList("namespace1"), new ArrayList<String>(this.installedExtension.getNamespaces())); |
123 |
|
|
124 |
1 |
this.installedExtension.setInstalled(true, "namespace2"); |
125 |
|
|
126 |
1 |
Assert.assertEquals(new HashSet<String>(Arrays.asList("namespace1", "namespace2")), new HashSet<String>( |
127 |
|
this.installedExtension.getNamespaces())); |
128 |
|
|
129 |
1 |
this.installedExtension.setNamespaces(Arrays.asList("namespace3")); |
130 |
|
|
131 |
1 |
Assert |
132 |
|
.assertEquals(Arrays.asList("namespace3"), new ArrayList<String>(this.installedExtension.getNamespaces())); |
133 |
|
|
134 |
|
} |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
136 |
1 |
@Test... |
137 |
|
public void testSetInstallDate() |
138 |
|
{ |
139 |
1 |
Date date = new Date(13); |
140 |
|
|
141 |
1 |
this.installedExtension.setInstallDate(date, "foo"); |
142 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate("foo")); |
143 |
|
|
144 |
1 |
this.installedExtension.setInstallDate(date, null); |
145 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate(null)); |
146 |
|
|
147 |
1 |
this.installedExtension.setInstalled(true, "foo"); |
148 |
1 |
this.installedExtension.setInstallDate(date, "foo"); |
149 |
1 |
Assert.assertEquals(date, this.installedExtension.getInstallDate("foo")); |
150 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate("bar")); |
151 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate(null)); |
152 |
|
|
153 |
1 |
this.installedExtension.setInstalled(false, "foo"); |
154 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate("foo")); |
155 |
|
|
156 |
1 |
this.installedExtension.setInstalled(true, null); |
157 |
1 |
this.installedExtension.setInstallDate(date, null); |
158 |
1 |
Assert.assertEquals(date, this.installedExtension.getInstallDate(null)); |
159 |
1 |
Assert.assertEquals(date, this.installedExtension.getInstallDate("foo")); |
160 |
|
|
161 |
1 |
this.installedExtension.setInstalled(false, null); |
162 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate(null)); |
163 |
1 |
Assert.assertNull(this.installedExtension.getInstallDate("foo")); |
164 |
|
|
165 |
1 |
this.installedExtension.setInstalled(true, "foo"); |
166 |
1 |
this.installedExtension.setInstallDate(new Date(27), "foo"); |
167 |
1 |
this.installedExtension.setInstalled(true, null); |
168 |
1 |
this.installedExtension.setInstallDate(date, null); |
169 |
1 |
Assert.assertEquals(date, this.installedExtension.getInstallDate(null)); |
170 |
1 |
Assert.assertEquals(date, this.installedExtension.getInstallDate("foo")); |
171 |
|
} |
172 |
|
} |