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.Rule; |
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.model.internal.DefaultModelConfiguration; |
26 |
|
import org.xwiki.model.internal.reference.DefaultSymbolScheme; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
29 |
|
import org.xwiki.test.annotation.ComponentList; |
30 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
31 |
|
|
32 |
|
import com.xpn.xwiki.test.MockitoOldcoreRule; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@ComponentList({ |
41 |
|
DefaultSymbolScheme.class, |
42 |
|
CurrentEntityReferenceProvider.class, |
43 |
|
DefaultModelConfiguration.class |
44 |
|
}) |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
45 |
|
public class CompactWikiStringEntityReferenceSerializerTest |
46 |
|
{ |
47 |
|
public MockitoComponentMockingRule<EntityReferenceSerializer<String>> mocker = |
48 |
|
new MockitoComponentMockingRule<EntityReferenceSerializer<String>>( |
49 |
|
CompactWikiStringEntityReferenceSerializer.class); |
50 |
|
|
51 |
|
@Rule |
52 |
|
public MockitoOldcoreRule oldcore = new MockitoOldcoreRule(this.mocker); |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void testSerializeWhenInSameWiki() throws Exception |
56 |
|
{ |
57 |
1 |
DocumentReference reference = new DocumentReference("wiki", "space", "page"); |
58 |
|
|
59 |
1 |
this.oldcore.getXWikiContext().setWikiReference(reference.getWikiReference()); |
60 |
|
|
61 |
1 |
Assert.assertEquals("space.page", this.mocker.getComponentUnderTest().serialize(reference)); |
62 |
1 |
Assert.assertEquals("space", this.mocker.getComponentUnderTest().serialize(reference.getParent())); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testSerializeWhenNotInSameWiki() throws Exception |
67 |
|
{ |
68 |
1 |
DocumentReference reference = new DocumentReference("wiki", "space", "page"); |
69 |
|
|
70 |
1 |
this.oldcore.getXWikiContext().setWikiId("otherwiki"); |
71 |
|
|
72 |
1 |
Assert.assertEquals("wiki:space.page", this.mocker.getComponentUnderTest().serialize(reference)); |
73 |
1 |
Assert.assertEquals("wiki:space", this.mocker.getComponentUnderTest().serialize(reference.getParent())); |
74 |
|
} |
75 |
|
} |