1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.model.reference; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.xwiki.model.EntityType; |
24 |
|
|
25 |
|
import static org.junit.Assert.assertEquals; |
26 |
|
import static org.junit.Assert.fail; |
27 |
|
|
28 |
|
|
29 |
|
@link |
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 83.3% |
Uncovered Elements: 3 (18) |
Complexity: 7 |
Complexity Density: 0.5 |
|
34 |
|
public class ObjectReferenceTest |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
39 |
1 |
@Test... |
40 |
|
public void testConstructors() |
41 |
|
{ |
42 |
1 |
ObjectReference reference = |
43 |
|
new ObjectReference(new EntityReference("Object", EntityType.OBJECT, new EntityReference("Page", |
44 |
|
EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
45 |
|
EntityType.WIKI))))); |
46 |
1 |
assertEquals(reference, new ObjectReference("Object", new DocumentReference("wiki", "Space", "Page"))); |
47 |
|
} |
48 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void testInvalidType() |
51 |
|
{ |
52 |
1 |
try { |
53 |
1 |
new ObjectReference(new EntityReference("className", EntityType.DOCUMENT)); |
54 |
0 |
fail("Should have thrown exception"); |
55 |
|
} catch (IllegalArgumentException expected) { |
56 |
1 |
assertEquals("Invalid type [DOCUMENT] for an object reference", expected.getMessage()); |
57 |
|
} |
58 |
|
} |
59 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testInvalidNullParent() |
62 |
|
{ |
63 |
1 |
try { |
64 |
1 |
new ObjectReference(new EntityReference("className", EntityType.OBJECT, null)); |
65 |
0 |
fail("Should have thrown exception"); |
66 |
|
} catch (IllegalArgumentException expected) { |
67 |
1 |
assertEquals("Invalid parent reference [null] in an object reference", expected.getMessage()); |
68 |
|
} |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
74 |
1 |
@Test... |
75 |
|
public void testInvalidParentType() |
76 |
|
{ |
77 |
1 |
try { |
78 |
1 |
new ObjectReference(new EntityReference("className", EntityType.OBJECT, new EntityReference("Space", |
79 |
|
EntityType.SPACE))); |
80 |
0 |
fail("Should have thrown exception"); |
81 |
|
} catch (IllegalArgumentException expected) { |
82 |
1 |
assertEquals("Invalid parent reference [Space Space] in an object reference", expected.getMessage()); |
83 |
|
} |
84 |
|
} |
85 |
|
} |