1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.resources.app.availability; |
35 |
|
|
36 |
|
import static org.hamcrest.Matchers.is; |
37 |
|
import static org.junit.Assert.assertThat; |
38 |
|
import static org.mockito.BDDMockito.given; |
39 |
|
import static org.mockito.Matchers.anyString; |
40 |
|
import static org.mockito.Mockito.mock; |
41 |
|
|
42 |
|
import info.magnolia.resourceloader.ResourceOrigin; |
43 |
|
import info.magnolia.resourceloader.layered.LayeredResource; |
44 |
|
|
45 |
|
import org.junit.Before; |
46 |
|
import org.junit.Test; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.11 |
|
48 |
|
public class IsEditableRuleTest { |
49 |
|
|
50 |
|
private static final String NOT_EDITABLE_RESOURCE_PATH = "/a.txt"; |
51 |
|
private static final String EDITABLE_RESOURCE_PATH = "/b.txt"; |
52 |
|
|
53 |
|
private IsEditableRule rule; |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
55 |
1 |
@Before... |
56 |
|
public void setUp() throws Exception { |
57 |
1 |
ResourceOrigin origin = mock(ResourceOrigin.class); |
58 |
1 |
rule = new IsEditableRule(origin); |
59 |
|
|
60 |
1 |
LayeredResource notEditableResource = mock(LayeredResource.class); |
61 |
1 |
LayeredResource editableResource = mock(LayeredResource.class); |
62 |
|
|
63 |
1 |
given(origin.hasPath(anyString())).willReturn(true); |
64 |
|
|
65 |
1 |
given(origin.getByPath(NOT_EDITABLE_RESOURCE_PATH)).willReturn(notEditableResource); |
66 |
1 |
given(origin.getByPath(EDITABLE_RESOURCE_PATH)).willReturn(editableResource); |
67 |
|
|
68 |
|
|
69 |
1 |
given(notEditableResource.isEditable()).willReturn(false); |
70 |
1 |
given(editableResource.isEditable()).willReturn(true); |
71 |
|
} |
72 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
73 |
|
@Test... |
74 |
|
public void isAvailableOnlyForEditableResourcePaths() { |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
assertThat(rule.isAvailableForItem(NOT_EDITABLE_RESOURCE_PATH), is(false)); |
80 |
|
assertThat(rule.isAvailableForItem(EDITABLE_RESOURCE_PATH), is(true)); |
81 |
|
} |
82 |
|
} |