1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.context; |
21 |
|
|
22 |
|
import static org.hamcrest.Matchers.hasEntry; |
23 |
|
import static org.junit.Assert.assertEquals; |
24 |
|
import static org.junit.Assert.assertNull; |
25 |
|
import static org.junit.Assert.assertThat; |
26 |
|
import static org.junit.Assert.assertTrue; |
27 |
|
|
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.Map; |
30 |
|
|
31 |
|
import org.junit.Test; |
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (38) |
Complexity: 6 |
Complexity Density: 0.19 |
|
37 |
|
public class ExecutionContextTest |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
39 |
1 |
@Test... |
40 |
|
public void inheritance() |
41 |
|
{ |
42 |
1 |
ExecutionContext context = new ExecutionContext(); |
43 |
1 |
ExecutionContext parent = new ExecutionContext(); |
44 |
|
|
45 |
1 |
parent.newProperty("inherited").inherited().initial("test").declare(); |
46 |
|
|
47 |
1 |
parent.newProperty("shadowed").inherited().initial("original").declare(); |
48 |
|
|
49 |
1 |
context.newProperty("shadowed").inherited().initial("shadowed").declare(); |
50 |
|
|
51 |
1 |
context.inheritFrom(parent); |
52 |
|
|
53 |
1 |
assertTrue(context.getProperty("inherited").equals("test")); |
54 |
1 |
assertTrue(context.getProperty("shadowed").equals("shadowed")); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
57 |
1 |
@Test(expected = IllegalStateException.class)... |
58 |
|
public void illegalInheritance() |
59 |
|
{ |
60 |
1 |
ExecutionContext context = new ExecutionContext(); |
61 |
1 |
ExecutionContext parent = new ExecutionContext(); |
62 |
|
|
63 |
1 |
parent.newProperty("inherited").inherited().initial("test").makeFinal().declare(); |
64 |
1 |
context.newProperty("inherited").inherited().initial("test").makeFinal().declare(); |
65 |
|
|
66 |
1 |
context.inheritFrom(parent); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void getProperties() |
71 |
|
{ |
72 |
1 |
ExecutionContext context = new ExecutionContext(); |
73 |
1 |
context.setProperty("key", "value"); |
74 |
1 |
Map<String, Object> properties = context.getProperties(); |
75 |
1 |
assertEquals(1, properties.size()); |
76 |
1 |
assertThat(properties, hasEntry("key", (Object) "value")); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
79 |
1 |
@Test... |
80 |
|
public void setProperties() |
81 |
|
{ |
82 |
1 |
Map<String, Object> properties = new HashMap<String, Object>(); |
83 |
1 |
properties.put("key1", "value1"); |
84 |
1 |
properties.put("key2", "value2"); |
85 |
|
|
86 |
1 |
ExecutionContext context = new ExecutionContext(); |
87 |
1 |
context.setProperties(properties); |
88 |
|
|
89 |
1 |
assertEquals("value1", context.getProperty("key1")); |
90 |
1 |
assertEquals("value2", context.getProperty("key2")); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
public void removeProperty() |
95 |
|
{ |
96 |
1 |
ExecutionContext context = new ExecutionContext(); |
97 |
1 |
context.setProperty("key", "value"); |
98 |
|
|
99 |
1 |
assertEquals("value", context.getProperty("key")); |
100 |
|
|
101 |
1 |
context.removeProperty("key"); |
102 |
|
|
103 |
1 |
assertNull(context.getProperty("key")); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
106 |
1 |
@Test... |
107 |
|
public void removeUnexistingProperty() |
108 |
|
{ |
109 |
1 |
ExecutionContext context = new ExecutionContext(); |
110 |
1 |
context.removeProperty("doesnotexist"); |
111 |
|
} |
112 |
|
} |