1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.model.reference; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.model.EntityType; |
25 |
|
import org.xwiki.model.reference.DocumentReference; |
26 |
|
import org.xwiki.model.reference.EntityReference; |
27 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
28 |
|
|
29 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
30 |
|
import com.xpn.xwiki.test.AbstractBridgedComponentTestCase; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 3 |
Complexity Density: 0.17 |
|
37 |
|
public class CurrentReferenceEntityReferenceResolverTest extends AbstractBridgedComponentTestCase |
38 |
|
{ |
39 |
|
private static final String CURRENT_WIKI = "currentwiki"; |
40 |
|
|
41 |
|
private static final String CURRENT_SPACE = "currentspace"; |
42 |
|
|
43 |
|
private static final String CURRENT_PAGE = "currentpage"; |
44 |
|
|
45 |
|
private EntityReferenceResolver<EntityReference> resolver; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
47 |
2 |
@Override... |
48 |
|
public void setUp() throws Exception |
49 |
|
{ |
50 |
2 |
super.setUp(); |
51 |
|
|
52 |
2 |
this.resolver = getComponentManager().getInstance(EntityReferenceResolver.TYPE_REFERENCE, "current"); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void testResolveAttachmentReferenceWhenMissingParentsAndNoContextDocument() |
57 |
|
{ |
58 |
1 |
EntityReference reference = |
59 |
|
resolver.resolve(new EntityReference("filename", EntityType.ATTACHMENT), EntityType.ATTACHMENT); |
60 |
|
|
61 |
1 |
Assert.assertEquals("WebHome", reference.getParent().getName()); |
62 |
1 |
Assert.assertEquals(EntityType.DOCUMENT, reference.getParent().getType()); |
63 |
1 |
Assert.assertEquals("Main", reference.getParent().getParent().getName()); |
64 |
1 |
Assert.assertEquals(EntityType.SPACE, reference.getParent().getParent().getType()); |
65 |
1 |
Assert.assertEquals("xwiki", reference.getParent().getParent().getParent().getName()); |
66 |
1 |
Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getParent().getType()); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void testResolveAttachmentReferenceWhenMissingParentsAndContextDocument() |
71 |
|
{ |
72 |
1 |
getContext().setWikiId(CURRENT_WIKI); |
73 |
1 |
getContext().setDoc(new XWikiDocument(new DocumentReference("docwiki", CURRENT_SPACE, CURRENT_PAGE))); |
74 |
|
|
75 |
1 |
EntityReference reference = |
76 |
|
resolver.resolve(new EntityReference("filename", EntityType.ATTACHMENT), EntityType.ATTACHMENT); |
77 |
|
|
78 |
1 |
Assert.assertEquals(CURRENT_PAGE, reference.getParent().getName()); |
79 |
1 |
Assert.assertEquals(EntityType.DOCUMENT, reference.getParent().getType()); |
80 |
1 |
Assert.assertEquals(CURRENT_SPACE, reference.getParent().getParent().getName()); |
81 |
1 |
Assert.assertEquals(EntityType.SPACE, reference.getParent().getParent().getType()); |
82 |
1 |
Assert.assertEquals(CURRENT_WIKI, reference.getParent().getParent().getParent().getName()); |
83 |
1 |
Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getParent().getType()); |
84 |
|
} |
85 |
|
} |