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 |
|
import org.xwiki.model.reference.ObjectReference; |
29 |
|
|
30 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
31 |
|
import com.xpn.xwiki.test.AbstractBridgedComponentTestCase; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
@version |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 3 |
Complexity Density: 0.2 |
|
38 |
|
public class CurrentMixedReferenceEntityReferenceResolverTest extends AbstractBridgedComponentTestCase |
39 |
|
{ |
40 |
|
private static final String CURRENT_WIKI = "currentwiki"; |
41 |
|
|
42 |
|
private static final String CURRENT_SPACE = "currentspace"; |
43 |
|
|
44 |
|
private static final String CURRENT_PAGE = "currentpage"; |
45 |
|
|
46 |
|
private EntityReferenceResolver<EntityReference> resolver; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
48 |
2 |
@Override... |
49 |
|
public void setUp() throws Exception |
50 |
|
{ |
51 |
2 |
super.setUp(); |
52 |
|
|
53 |
2 |
this.resolver = getComponentManager().getInstance(EntityReferenceResolver.TYPE_REFERENCE, "currentmixed"); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void testResolveAttachmentReferenceWhenMissingParentsAndContextDocument() |
58 |
|
{ |
59 |
1 |
getContext().setWikiId(CURRENT_WIKI); |
60 |
1 |
getContext().setDoc(new XWikiDocument(new DocumentReference(CURRENT_WIKI, CURRENT_SPACE, CURRENT_PAGE))); |
61 |
|
|
62 |
1 |
EntityReference reference = |
63 |
|
resolver.resolve(new EntityReference("filename", EntityType.ATTACHMENT), EntityType.ATTACHMENT); |
64 |
|
|
65 |
1 |
Assert.assertEquals("WebHome", reference.getParent().getName()); |
66 |
1 |
Assert.assertEquals(EntityType.DOCUMENT, reference.getParent().getType()); |
67 |
1 |
Assert.assertEquals(CURRENT_SPACE, reference.getParent().getParent().getName()); |
68 |
1 |
Assert.assertEquals(EntityType.SPACE, reference.getParent().getParent().getType()); |
69 |
1 |
Assert.assertEquals(CURRENT_WIKI, reference.getParent().getParent().getParent().getName()); |
70 |
1 |
Assert.assertEquals(EntityType.WIKI, reference.getParent().getParent().getParent().getType()); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
73 |
1 |
@Test... |
74 |
|
public void testResolveDocumentFromObjectReference() |
75 |
|
{ |
76 |
1 |
DocumentReference documentReference = new DocumentReference("wiki", "space", "page"); |
77 |
1 |
ObjectReference objectReference = new ObjectReference("object", documentReference); |
78 |
|
|
79 |
1 |
EntityReference reference = this.resolver.resolve(objectReference, EntityType.DOCUMENT); |
80 |
|
|
81 |
1 |
Assert.assertEquals(documentReference, reference); |
82 |
|
} |
83 |
|
} |