1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.resource.internal.entity; |
21 |
|
|
22 |
|
import javax.inject.Provider; |
23 |
|
|
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.component.manager.ComponentManager; |
28 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
29 |
|
import org.xwiki.environment.Environment; |
30 |
|
import org.xwiki.resource.ResourceReferenceHandler; |
31 |
|
import org.xwiki.resource.entity.EntityResourceAction; |
32 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
33 |
|
|
34 |
|
import static org.junit.Assert.assertThat; |
35 |
|
import static org.hamcrest.CoreMatchers.hasItems; |
36 |
|
import static org.mockito.Mockito.*; |
37 |
|
|
38 |
|
|
39 |
|
@link |
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
44 |
|
public class DefaultEntityResourceActionListerTest |
45 |
|
{ |
46 |
|
@Rule |
47 |
|
public MockitoComponentMockingRule<DefaultEntityResourceActionLister> mocker = |
48 |
|
new MockitoComponentMockingRule<>(DefaultEntityResourceActionLister.class); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
1 |
@Before... |
51 |
|
public void configure() throws Exception |
52 |
|
{ |
53 |
1 |
Provider<ComponentManager> componentManagerProvider = this.mocker.registerMockComponent( |
54 |
|
new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context"); |
55 |
1 |
when(componentManagerProvider.get()).thenReturn(this.mocker); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
58 |
1 |
@Test... |
59 |
|
public void listActions() throws Exception |
60 |
|
{ |
61 |
1 |
Environment environment = this.mocker.getInstance(Environment.class); |
62 |
1 |
when(environment.getResourceAsStream("/WEB-INF/struts-config.xml")).thenReturn( |
63 |
|
getClass().getClassLoader().getResourceAsStream("WEB-INF/struts-config.xml")); |
64 |
|
|
65 |
1 |
this.mocker.registerMockComponent(new DefaultParameterizedType(null, ResourceReferenceHandler.class, |
66 |
|
EntityResourceAction.class), "testaction"); |
67 |
|
|
68 |
1 |
assertThat(this.mocker.getComponentUnderTest().listActions(), hasItems("view", "edit", "get", "testaction")); |
69 |
|
} |
70 |
|
} |