1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.model.internal; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.component.manager.ComponentLookupException; |
27 |
|
import org.xwiki.configuration.internal.MemoryConfigurationSource; |
28 |
|
import org.xwiki.model.EntityType; |
29 |
|
import org.xwiki.model.ModelConfiguration; |
30 |
|
import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer; |
31 |
|
import org.xwiki.model.internal.reference.RelativeStringEntityReferenceResolver; |
32 |
|
import org.xwiki.test.annotation.ComponentList; |
33 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@ComponentList({RelativeStringEntityReferenceResolver.class, DefaultStringEntityReferenceSerializer.class}) |
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 3 |
Complexity Density: 0.16 |
|
42 |
|
public class DefaultModelConfigurationTest |
43 |
|
{ |
44 |
|
@Rule |
45 |
|
public final MockitoComponentMockingRule<ModelConfiguration> mocker = |
46 |
|
new MockitoComponentMockingRule<ModelConfiguration>(DefaultModelConfiguration.class); |
47 |
|
|
48 |
|
private MemoryConfigurationSource configuration; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
2 |
@Before... |
51 |
|
public void before() throws Exception |
52 |
|
{ |
53 |
2 |
this.configuration = this.mocker.registerMemoryConfigurationSource(); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void testGetDefaultReferenceNameWhenDefinedInConfiguration() throws ComponentLookupException |
58 |
|
{ |
59 |
1 |
this.configuration.setProperty("model.reference.default.wiki", "defaultWiki"); |
60 |
1 |
this.configuration.setProperty("model.reference.default.document", "defaultDocument"); |
61 |
1 |
this.configuration.setProperty("model.reference.default.space", "defaultSpace"); |
62 |
1 |
this.configuration.setProperty("model.reference.default.attachment", "defaultFilename"); |
63 |
1 |
this.configuration.setProperty("model.reference.default.object", "defaultObject"); |
64 |
1 |
this.configuration.setProperty("model.reference.default.object_property", "defaultProperty"); |
65 |
|
|
66 |
1 |
Assert.assertEquals("defaultWiki", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.WIKI)); |
67 |
1 |
Assert.assertEquals("defaultDocument", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.DOCUMENT)); |
68 |
1 |
Assert.assertEquals("defaultSpace", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.SPACE)); |
69 |
1 |
Assert.assertEquals("defaultFilename", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.ATTACHMENT)); |
70 |
1 |
Assert.assertEquals("defaultObject", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.OBJECT)); |
71 |
1 |
Assert.assertEquals("defaultProperty", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.OBJECT_PROPERTY)); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
74 |
1 |
@Test... |
75 |
|
public void testGetDefaultReferenceNameWhenNotDefinedInConfiguration() throws ComponentLookupException |
76 |
|
{ |
77 |
1 |
Assert.assertEquals("xwiki", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.WIKI)); |
78 |
1 |
Assert.assertEquals("WebHome", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.DOCUMENT)); |
79 |
1 |
Assert.assertEquals("Main", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.SPACE)); |
80 |
1 |
Assert.assertEquals("filename", this.mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.ATTACHMENT)); |
81 |
1 |
Assert.assertEquals("object", mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.OBJECT)); |
82 |
1 |
Assert.assertEquals("property", mocker.getComponentUnderTest().getDefaultReferenceValue(EntityType.OBJECT_PROPERTY)); |
83 |
|
} |
84 |
|
} |