1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.url.internal.filesystem; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.context.Execution; |
25 |
|
import org.xwiki.context.ExecutionContext; |
26 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
27 |
|
import org.xwiki.url.filesystem.FilesystemExportContext; |
28 |
|
|
29 |
|
import static org.junit.Assert.*; |
30 |
|
import static org.mockito.Mockito.when; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
38 |
|
public class FilesystemExportContextProviderTest |
39 |
|
{ |
40 |
|
@Rule |
41 |
|
public MockitoComponentMockingRule<FilesystemExportContextProvider> mocker = |
42 |
|
new MockitoComponentMockingRule<>(FilesystemExportContextProvider.class); |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
44 |
1 |
@Test... |
45 |
|
public void getWhenExportContextNotInEC() throws Exception |
46 |
|
{ |
47 |
1 |
ExecutionContext ec = new ExecutionContext(); |
48 |
1 |
Execution execution = this.mocker.getInstance(Execution.class); |
49 |
1 |
when(execution.getContext()).thenReturn(ec); |
50 |
|
|
51 |
1 |
FilesystemExportContext fec = this.mocker.getComponentUnderTest().get(); |
52 |
1 |
assertSame(fec, ec.getProperty("filesystemExportContext")); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void getWhenExportContextAlreadyInEC() throws Exception |
57 |
|
{ |
58 |
1 |
ExecutionContext ec = new ExecutionContext(); |
59 |
1 |
FilesystemExportContext fec = new FilesystemExportContext(); |
60 |
1 |
ec.setProperty("filesystemExportContext", fec); |
61 |
1 |
Execution execution = this.mocker.getInstance(Execution.class); |
62 |
1 |
when(execution.getContext()).thenReturn(ec); |
63 |
|
|
64 |
1 |
FilesystemExportContext newfec = this.mocker.getComponentUnderTest().get(); |
65 |
1 |
assertSame(newfec, ec.getProperty("filesystemExportContext")); |
66 |
1 |
assertSame(newfec, fec); |
67 |
|
} |
68 |
|
} |