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 (16) |
Complexity: 3 |
Complexity Density: 0.23 |
|
37 |
|
public class CurrentMixedStringDocumentReferenceResolverTest extends AbstractBridgedComponentTestCase |
38 |
|
{ |
39 |
|
private static final String CURRENT_SPACE = "currentspace"; |
40 |
|
|
41 |
|
private EntityReferenceResolver<String> resolver; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
43 |
2 |
@Override... |
44 |
|
public void setUp() throws Exception |
45 |
|
{ |
46 |
2 |
super.setUp(); |
47 |
|
|
48 |
2 |
this.resolver = getComponentManager().getInstance(EntityReferenceResolver.TYPE_STRING, "currentmixed"); |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void testResolveDocumentReferenceWhenContextDocument() throws Exception |
53 |
|
{ |
54 |
1 |
getContext().setDoc(new XWikiDocument(new DocumentReference("not used", CURRENT_SPACE, "notused"))); |
55 |
|
|
56 |
1 |
getContext().setWikiId("currentwiki"); |
57 |
|
|
58 |
1 |
EntityReference reference = this.resolver.resolve("", EntityType.DOCUMENT); |
59 |
1 |
Assert.assertEquals("currentwiki", reference.extractReference(EntityType.WIKI).getName()); |
60 |
1 |
Assert.assertEquals(CURRENT_SPACE, reference.extractReference(EntityType.SPACE).getName()); |
61 |
1 |
Assert.assertEquals("WebHome", reference.getName()); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void testResolveDocumentReferenceForDefaultWikiWhenNoContextDocument() throws Exception |
66 |
|
{ |
67 |
1 |
getContext().setWikiId("currentwiki"); |
68 |
|
|
69 |
1 |
EntityReference reference = this.resolver.resolve("space.page", EntityType.DOCUMENT); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
1 |
Assert.assertEquals("currentwiki", reference.extractReference(EntityType.WIKI).getName()); |
74 |
|
|
75 |
1 |
Assert.assertEquals("space", reference.extractReference(EntityType.SPACE).getName()); |
76 |
1 |
Assert.assertEquals("page", reference.getName()); |
77 |
|
} |
78 |
|
} |