1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension; |
21 |
|
|
22 |
|
import org.junit.Before; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.extension.repository.ExtensionRepository; |
25 |
|
|
26 |
|
import static org.junit.Assert.assertEquals; |
27 |
|
import static org.junit.Assert.assertSame; |
28 |
|
import static org.mockito.Mockito.mock; |
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 5 |
Complexity Density: 0.24 |
|
33 |
|
public class AbstractExtensionTest |
34 |
|
{ |
35 |
|
private AbstractExtension extension; |
36 |
|
|
37 |
|
private ExtensionRepository repository; |
38 |
|
|
39 |
|
private ExtensionId id; |
40 |
|
|
41 |
|
private String type; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.33 |
|
43 |
|
private static class TestExtension extends AbstractExtension |
44 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
45 |
21 |
public TestExtension(ExtensionId id, String type, ExtensionId... features)... |
46 |
|
{ |
47 |
21 |
super(null, id, type); |
48 |
|
|
49 |
21 |
for (ExtensionId feature : features) { |
50 |
6 |
addExtensionFeature(feature); |
51 |
|
} |
52 |
|
} |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
21 |
private AbstractExtension toExtension(String id, String version, ExtensionId... features)... |
56 |
|
{ |
57 |
21 |
return new TestExtension(new ExtensionId(id, version), "test", features); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
11 |
private void assertCompareTo(int comparizon, Extension e1, Extension e2)... |
61 |
|
{ |
62 |
11 |
assertEquals(comparizon, e1.compareTo(e2)); |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
67 |
2 |
@Before... |
68 |
|
public void before() |
69 |
|
{ |
70 |
2 |
this.repository = mock(ExtensionRepository.class); |
71 |
2 |
this.id = new ExtensionId("extesionid", "extensionversion"); |
72 |
2 |
this.type = "extensiontype"; |
73 |
|
|
74 |
2 |
this.extension = new AbstractExtension(this.repository, this.id, this.type) |
75 |
|
{ |
76 |
|
}; |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
79 |
1 |
@Test... |
80 |
|
public void testGet() |
81 |
|
{ |
82 |
1 |
assertSame(this.repository, this.extension.get("repository")); |
83 |
1 |
assertEquals(this.id.getId(), this.extension.get("id")); |
84 |
1 |
assertEquals(this.id.getVersion(), this.extension.get("version")); |
85 |
1 |
assertEquals(this.type, this.extension.get("type")); |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
88 |
1 |
@Test... |
89 |
|
public void testCompareTo() |
90 |
|
{ |
91 |
1 |
assertCompareTo(0, toExtension("id", "2.0"), toExtension("id", "2.0")); |
92 |
1 |
assertCompareTo(-1, toExtension("id", "2.0"), toExtension("id", "3.0")); |
93 |
1 |
assertCompareTo(1, toExtension("id", "2.0"), toExtension("id", "1.0")); |
94 |
|
|
95 |
1 |
assertCompareTo(0, toExtension("feature", "2.0"), toExtension("id", "2.0", new ExtensionId("feature", "2.0"))); |
96 |
1 |
assertCompareTo(-1, toExtension("feature", "2.0"), toExtension("id", "2.0", new ExtensionId("feature", "3.0"))); |
97 |
1 |
assertCompareTo(1, toExtension("feature", "2.0"), toExtension("id", "2.0", new ExtensionId("feature", "1.0"))); |
98 |
|
|
99 |
1 |
assertCompareTo(0, toExtension("id", "2.0", new ExtensionId("feature", "2.0")), toExtension("feature", "2.0")); |
100 |
1 |
assertCompareTo(-1, toExtension("id", "2.0", new ExtensionId("feature", "2.0")), toExtension("feature", "3.0")); |
101 |
1 |
assertCompareTo(1, toExtension("id", "2.0", new ExtensionId("feature", "2.0")), toExtension("feature", "1.0")); |
102 |
|
|
103 |
1 |
assertCompareTo(-1, toExtension("id", "1.0"), toExtension("id2", "1.0")); |
104 |
|
|
105 |
1 |
assertCompareTo(-1, toExtension("id", "1.0"), null); |
106 |
|
} |
107 |
|
} |