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 ObjectPropertyReferenceTest |
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 |
ObjectPropertyReference reference = |
43 |
|
new ObjectPropertyReference(new EntityReference("property", EntityType.OBJECT_PROPERTY, |
44 |
|
new EntityReference("Object", EntityType.OBJECT, new EntityReference("Page", EntityType.DOCUMENT, |
45 |
|
new EntityReference("Space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)))))); |
46 |
1 |
assertEquals(reference, new ObjectPropertyReference("property", new ObjectReference("Object", |
47 |
|
new DocumentReference("wiki", "Space", "Page")))); |
48 |
|
} |
49 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void testInvalidType() |
52 |
|
{ |
53 |
1 |
try { |
54 |
1 |
new ObjectPropertyReference(new EntityReference("space.page", EntityType.DOCUMENT)); |
55 |
0 |
fail("Should have thrown exception"); |
56 |
|
} catch (IllegalArgumentException expected) { |
57 |
1 |
assertEquals("Invalid type [DOCUMENT] for an object property reference", expected.getMessage()); |
58 |
|
} |
59 |
|
} |
60 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
61 |
1 |
@Test... |
62 |
|
public void testInvalidNullParent() |
63 |
|
{ |
64 |
1 |
try { |
65 |
1 |
new ObjectPropertyReference(new EntityReference("property", EntityType.OBJECT_PROPERTY, null)); |
66 |
0 |
fail("Should have thrown exception"); |
67 |
|
} catch (IllegalArgumentException expected) { |
68 |
1 |
assertEquals("Invalid parent reference [null] in an object property reference", expected.getMessage()); |
69 |
|
} |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void testInvalidParentType() |
77 |
|
{ |
78 |
1 |
try { |
79 |
1 |
new ObjectPropertyReference(new EntityReference("property", EntityType.OBJECT_PROPERTY, |
80 |
|
new EntityReference("Space", EntityType.SPACE))); |
81 |
0 |
fail("Should have thrown exception"); |
82 |
|
} catch (IllegalArgumentException expected) { |
83 |
1 |
assertEquals("Invalid parent reference [Space Space] in an object property reference", |
84 |
|
expected.getMessage()); |
85 |
|
} |
86 |
|
} |
87 |
|
} |