1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.url; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.context.ExecutionContext; |
25 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
26 |
|
import org.xwiki.url.internal.URLExecutionContextInitializer; |
27 |
|
|
28 |
|
import static org.junit.Assert.assertEquals; |
29 |
|
import static org.mockito.Mockito.when; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
37 |
|
public class URLExecutionContextInitializerTest |
38 |
|
{ |
39 |
|
@Rule |
40 |
|
public MockitoComponentMockingRule<URLExecutionContextInitializer> mocker = |
41 |
|
new MockitoComponentMockingRule<>(URLExecutionContextInitializer.class); |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
43 |
1 |
@Test... |
44 |
|
public void initializeWhenFormatIdNotInContext() throws Exception |
45 |
|
{ |
46 |
1 |
ExecutionContext ec = new ExecutionContext(); |
47 |
1 |
URLConfiguration configuration = this.mocker.getInstance(URLConfiguration.class); |
48 |
1 |
when(configuration.getURLFormatId()).thenReturn("test"); |
49 |
|
|
50 |
1 |
this.mocker.getComponentUnderTest().initialize(ec); |
51 |
|
|
52 |
1 |
assertEquals("test", ec.getProperty("urlscheme")); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void initializeWhenFormatIdAlreadyInContext() throws Exception |
57 |
|
{ |
58 |
1 |
ExecutionContext ec = new ExecutionContext(); |
59 |
1 |
ec.setProperty("urlscheme", "existing"); |
60 |
1 |
this.mocker.getComponentUnderTest().initialize(ec); |
61 |
|
|
62 |
1 |
assertEquals("existing", ec.getProperty("urlscheme")); |
63 |
|
} |
64 |
|
} |