1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.version.internal; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.extension.version.IncompatibleVersionConstraintException; |
27 |
|
import org.xwiki.extension.version.InvalidVersionRangeException; |
28 |
|
|
|
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 6 |
Complexity Density: 0.33 |
|
29 |
|
public class DefaultVersionConstraintTest |
30 |
|
{ |
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
1PASS
|
|
31 |
1 |
@Test... |
32 |
|
public void testMerge() throws IncompatibleVersionConstraintException |
33 |
|
{ |
34 |
1 |
Assert.assertEquals("2.0", new DefaultVersionConstraint("1.0").merge(new DefaultVersionConstraint("2.0")) |
35 |
|
.getValue()); |
36 |
1 |
Assert.assertEquals("{[1.0,2.0]},{[2.0]}", |
37 |
|
new DefaultVersionConstraint("[1.0,2.0]").merge(new DefaultVersionConstraint("[2.0]")).getValue()); |
38 |
1 |
Assert.assertEquals("2.0", new DefaultVersionConstraint("[1.0,2.0]").merge(new DefaultVersionConstraint("2.0")) |
39 |
|
.getValue()); |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
1 |
try { |
44 |
1 |
new DefaultVersionConstraint("[1.0]").merge(new DefaultVersionConstraint("[2.0]")).getValue(); |
45 |
0 |
Assert.fail("Should have failed"); |
46 |
|
} catch (IncompatibleVersionConstraintException expected) { |
47 |
|
|
48 |
|
} |
49 |
|
|
50 |
1 |
try { |
51 |
1 |
new DefaultVersionConstraint("1.0").merge(new DefaultVersionConstraint("[2.0]")).getValue(); |
52 |
0 |
Assert.fail("Should have failed"); |
53 |
|
} catch (IncompatibleVersionConstraintException expected) { |
54 |
|
|
55 |
|
} |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
58 |
1 |
@Test... |
59 |
|
public void testParse() throws InvalidVersionRangeException |
60 |
|
{ |
61 |
1 |
Assert.assertEquals("1.0", new DefaultVersionConstraint("1.0").getVersion().getValue()); |
62 |
1 |
Assert.assertEquals(Arrays.asList(new DefaultVersionRangeCollection("[1.0]")), new DefaultVersionConstraint( |
63 |
|
"[1.0]").getRanges()); |
64 |
1 |
Assert.assertEquals(Arrays.asList(new DefaultVersionRangeCollection("[1.0]")), new DefaultVersionConstraint( |
65 |
|
"{[1.0]}").getRanges()); |
66 |
1 |
Assert.assertEquals(Arrays.asList(new DefaultVersionRangeCollection("[1.0]"), |
67 |
|
new DefaultVersionRangeCollection("[1.0,2.0],[1.0]")), new DefaultVersionConstraint( |
68 |
|
"{[1.0]},{[1.0,2.0],[1.0]}").getRanges()); |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
1 |
Assert.assertEquals("[1.0", new DefaultVersionConstraint("[1.0").getVersion().getValue()); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void testContainsVersion() |
77 |
|
{ |
78 |
1 |
Assert.assertTrue(new DefaultVersionConstraint("1.0").containsVersion(new DefaultVersion("1.0"))); |
79 |
1 |
Assert.assertFalse(new DefaultVersionConstraint("1.0").containsVersion(new DefaultVersion("2.0"))); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
82 |
1 |
@Test... |
83 |
|
public void testIsCompatible() |
84 |
|
{ |
85 |
1 |
Assert.assertTrue(new DefaultVersionConstraint("1.0").isCompatible(new DefaultVersion("1.0"))); |
86 |
1 |
Assert.assertTrue(new DefaultVersionConstraint("1.0").isCompatible(new DefaultVersion("2.0"))); |
87 |
|
} |
88 |
|
} |