1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.annotation.reference; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.xwiki.model.EntityType; |
24 |
|
import org.xwiki.model.reference.EntityReference; |
25 |
|
|
26 |
|
import static org.junit.Assert.assertEquals; |
27 |
|
import static org.junit.Assert.assertNull; |
28 |
|
|
29 |
|
|
30 |
|
@link |
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 83.3% |
Uncovered Elements: 6 (36) |
Complexity: 8 |
Complexity Density: 0.29 |
|
35 |
|
public class IndexedObjectReferenceTest |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
40 |
1 |
@Test... |
41 |
|
public void testConstructors() |
42 |
|
{ |
43 |
1 |
IndexedObjectReference reference1 = |
44 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class[2]", EntityType.OBJECT, new EntityReference( |
45 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
46 |
|
EntityType.WIKI))))); |
47 |
1 |
IndexedObjectReference reference2 = |
48 |
|
new IndexedObjectReference("XWiki.Class", 2, new EntityReference("Page", EntityType.DOCUMENT, |
49 |
|
new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)))); |
50 |
1 |
assertEquals(reference1, reference2); |
51 |
1 |
assertEquals(reference1.getClassName(), reference2.getClassName()); |
52 |
1 |
assertEquals(reference1.getObjectNumber(), reference2.getObjectNumber()); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
58 |
0 |
public void testConstructorsWhenNonIndexedReference()... |
59 |
|
{ |
60 |
0 |
IndexedObjectReference reference1 = |
61 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class", EntityType.OBJECT, new EntityReference( |
62 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
63 |
|
EntityType.WIKI))))); |
64 |
0 |
IndexedObjectReference reference2 = |
65 |
|
new IndexedObjectReference("XWiki.Class", null, new EntityReference("Page", EntityType.DOCUMENT, |
66 |
|
new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)))); |
67 |
0 |
assertEquals(reference1, reference2); |
68 |
0 |
assertEquals(reference1.getClassName(), reference2.getClassName()); |
69 |
0 |
assertEquals(reference1.getObjectNumber(), reference2.getObjectNumber()); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
72 |
1 |
@Test... |
73 |
|
public void testObjectNumber() |
74 |
|
{ |
75 |
1 |
IndexedObjectReference reference = |
76 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class[2]", EntityType.OBJECT, new EntityReference( |
77 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
78 |
|
EntityType.WIKI))))); |
79 |
1 |
assertEquals("XWiki.Class", reference.getClassName()); |
80 |
1 |
assertEquals(new Integer(2), reference.getObjectNumber()); |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void testObjectNumberWhenDefaultObject() |
85 |
|
{ |
86 |
1 |
IndexedObjectReference reference = |
87 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class", EntityType.OBJECT, new EntityReference( |
88 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
89 |
|
EntityType.WIKI))))); |
90 |
1 |
assertEquals("XWiki.Class", reference.getClassName()); |
91 |
1 |
assertNull(reference.getObjectNumber()); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
94 |
1 |
@Test... |
95 |
|
public void testClassNameWhenRelativeClass() |
96 |
|
{ |
97 |
1 |
IndexedObjectReference reference = |
98 |
|
new IndexedObjectReference(new EntityReference("Class", EntityType.OBJECT, new EntityReference("Page", |
99 |
|
EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
100 |
|
EntityType.WIKI))))); |
101 |
1 |
assertEquals("Class", reference.getClassName()); |
102 |
1 |
assertNull(reference.getObjectNumber()); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
105 |
1 |
@Test... |
106 |
|
public void testObjectNumberWhenNonPairedSeparators() |
107 |
|
{ |
108 |
1 |
IndexedObjectReference reference = |
109 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class0]", EntityType.OBJECT, new EntityReference( |
110 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
111 |
|
EntityType.WIKI))))); |
112 |
1 |
assertEquals("XWiki.Class0]", reference.getClassName()); |
113 |
1 |
assertNull(reference.getObjectNumber()); |
114 |
|
} |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
116 |
1 |
@Test... |
117 |
|
public void testObjectNumberWhenNameContainsSeparators() |
118 |
|
{ |
119 |
1 |
IndexedObjectReference reference = |
120 |
|
new IndexedObjectReference(new EntityReference("XW[iki.C]lass[0]", EntityType.OBJECT, new EntityReference( |
121 |
|
"Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", |
122 |
|
EntityType.WIKI))))); |
123 |
1 |
assertEquals("XW[iki.C]lass", reference.getClassName()); |
124 |
1 |
assertEquals(new Integer(0), reference.getObjectNumber()); |
125 |
|
} |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
127 |
1 |
@Test... |
128 |
|
public void testObjectNumberWhenIndexNotNumber() |
129 |
|
{ |
130 |
1 |
IndexedObjectReference reference = |
131 |
|
new IndexedObjectReference(new EntityReference("XWiki.Class[number]", EntityType.OBJECT, |
132 |
|
new EntityReference("Page", EntityType.DOCUMENT, new EntityReference("Space", EntityType.SPACE, |
133 |
|
new EntityReference("wiki", EntityType.WIKI))))); |
134 |
1 |
assertEquals("XWiki.Class[number]", reference.getClassName()); |
135 |
1 |
assertNull(reference.getObjectNumber()); |
136 |
|
} |
137 |
|
} |