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.reference; |
21 |
|
|
22 |
|
import org.jmock.Expectations; |
23 |
|
import org.jmock.Mockery; |
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.component.util.ReflectionUtils; |
28 |
|
import org.xwiki.model.EntityType; |
29 |
|
import org.xwiki.model.ModelConfiguration; |
30 |
|
import org.xwiki.model.reference.EntityReferenceValueProvider; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 3 |
Complexity Density: 0.19 |
|
38 |
|
public class DefaultEntityReferenceValueProviderTest |
39 |
|
{ |
40 |
|
private Mockery mockery = new Mockery(); |
41 |
|
|
42 |
|
private EntityReferenceValueProvider provider; |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
44 |
1 |
@Before... |
45 |
|
public void setUp() |
46 |
|
{ |
47 |
1 |
this.provider = new DefaultEntityReferenceValueProvider(); |
48 |
1 |
final ModelConfiguration mockConfiguration = this.mockery.mock(ModelConfiguration.class); |
49 |
1 |
ReflectionUtils.setFieldValue(this.provider, "configuration", mockConfiguration); |
50 |
|
|
51 |
1 |
this.mockery.checking(new Expectations() |
52 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
53 |
1 |
{... |
54 |
1 |
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.SPACE); |
55 |
1 |
will(returnValue("defspace")); |
56 |
1 |
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.WIKI); |
57 |
1 |
will(returnValue("defwiki")); |
58 |
1 |
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.DOCUMENT); |
59 |
1 |
will(returnValue("defpage")); |
60 |
1 |
allowing(mockConfiguration).getDefaultReferenceValue(EntityType.ATTACHMENT); |
61 |
1 |
will(returnValue("deffilename")); |
62 |
|
} |
63 |
|
}); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void testGetDefaultValue() |
68 |
|
{ |
69 |
1 |
Assert.assertEquals("defpage", this.provider.getDefaultValue(EntityType.DOCUMENT)); |
70 |
1 |
Assert.assertEquals("defspace", this.provider.getDefaultValue(EntityType.SPACE)); |
71 |
1 |
Assert.assertEquals("deffilename", this.provider.getDefaultValue(EntityType.ATTACHMENT)); |
72 |
1 |
Assert.assertEquals("defwiki", this.provider.getDefaultValue(EntityType.WIKI)); |
73 |
|
} |
74 |
|
} |