1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.bridge; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
|
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.bridge.event.ActionExecutedEvent; |
26 |
|
import org.xwiki.bridge.event.ActionExecutingEvent; |
27 |
|
|
28 |
|
|
29 |
|
@link |
30 |
|
|
31 |
|
@version |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (89) |
Complexity: 28 |
Complexity Density: 0.46 |
|
33 |
|
public class ActionExecutingEventTest |
34 |
|
{ |
35 |
|
|
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
37 |
1 |
@Test... |
38 |
|
public void testDefaultConstructor() |
39 |
|
{ |
40 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent(); |
41 |
1 |
Assert.assertNull("A default action was used!", event.getActionName()); |
42 |
1 |
Assert.assertFalse("Event was created canceled!", event.isCanceled()); |
43 |
1 |
Assert.assertNull("A cancel reason was initially set!", event.getReason()); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void testConstructorWithActionName() |
48 |
|
{ |
49 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
50 |
1 |
Assert.assertEquals("Action name was lost!", "something", event.getActionName()); |
51 |
1 |
Assert.assertFalse("Event was created canceled!", event.isCanceled()); |
52 |
1 |
Assert.assertNull("A cancel reason was initially set!", event.getReason()); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void testCancel() |
59 |
|
{ |
60 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
61 |
1 |
Assert.assertFalse("Event was created canceled!", event.isCanceled()); |
62 |
1 |
event.cancel(); |
63 |
1 |
Assert.assertTrue("Event wasn't canceled when requested!", event.isCanceled()); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void testCancelWithReason() |
68 |
|
{ |
69 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
70 |
1 |
event.cancel("Testing reason"); |
71 |
1 |
Assert.assertEquals("Cancelling reason was lost!", "Testing reason", event.getReason()); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
76 |
1 |
@Test... |
77 |
|
public void testMatchesSameObject() |
78 |
|
{ |
79 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
80 |
1 |
Assert.assertTrue("Same object wasn't matched!", event.matches(event)); |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void testMatchesSameAction() |
85 |
|
{ |
86 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
87 |
1 |
Assert.assertTrue("Same action wasn't matched!", event.matches(new ActionExecutingEvent("something"))); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
90 |
1 |
@Test... |
91 |
|
public void testDoesntMatchNull() |
92 |
|
{ |
93 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
94 |
1 |
Assert.assertFalse("null was matched!", event.matches(null)); |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
97 |
1 |
@Test... |
98 |
|
public void testDoesntMatchWildcardAction() |
99 |
|
{ |
100 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
101 |
1 |
Assert.assertFalse("Wildcard action was matched!", event.matches(new ActionExecutingEvent())); |
102 |
|
} |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
104 |
1 |
@Test... |
105 |
|
public void testDoesntMatchDifferentAction() |
106 |
|
{ |
107 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
108 |
1 |
Assert.assertFalse("A different action was matched!", event.matches(new ActionExecutingEvent("else"))); |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
111 |
1 |
@Test... |
112 |
|
public void testDoesntMatchDifferentCaseAction() |
113 |
|
{ |
114 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
115 |
1 |
Assert.assertFalse("Action matching was case insensitive!", |
116 |
|
event.matches(new ActionExecutingEvent("SomeThing"))); |
117 |
|
} |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
119 |
1 |
@Test... |
120 |
|
public void testDoesntMatchDifferentTypeOfAction() |
121 |
|
{ |
122 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
123 |
1 |
Assert.assertFalse("A different type of action was matched!", |
124 |
|
event.matches(new ActionExecutedEvent("something"))); |
125 |
|
} |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
127 |
1 |
@Test... |
128 |
|
public void testWildcardActionMatchesAll() |
129 |
|
{ |
130 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
131 |
1 |
Assert.assertTrue("Wildcard action didn't match!", new ActionExecutingEvent().matches(event)); |
132 |
1 |
Assert.assertTrue("Wildcard action didn't match another wildcard action!", |
133 |
|
new ActionExecutingEvent().matches(new ActionExecutingEvent())); |
134 |
|
} |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
136 |
1 |
@Test... |
137 |
|
public void testWildcardActionDoesnMatchNull() |
138 |
|
{ |
139 |
1 |
Assert.assertFalse("Wildcard action matched null!", new ActionExecutingEvent().matches(null)); |
140 |
|
} |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
142 |
1 |
@Test... |
143 |
|
public void testEmptyActionDoesntMatch() |
144 |
|
{ |
145 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
146 |
1 |
Assert.assertFalse("Empty action behaves as wildcard!", new ActionExecutingEvent("").matches(event)); |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
151 |
1 |
@Test... |
152 |
|
public void testEqualsSameObject() |
153 |
|
{ |
154 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
155 |
1 |
Assert.assertTrue("Same object wasn't equal!", event.equals(event)); |
156 |
|
} |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
158 |
1 |
@Test... |
159 |
|
public void testEqualsSameAction() |
160 |
|
{ |
161 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
162 |
1 |
Assert.assertTrue("Same action wasn't equal!", event.equals(new ActionExecutingEvent("something"))); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
165 |
1 |
@Test... |
166 |
|
public void testEqualsWithNull() |
167 |
|
{ |
168 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
169 |
1 |
Assert.assertFalse("null was equal!", event.equals(null)); |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
172 |
1 |
@Test... |
173 |
|
public void testDoesntEqualWildcardAction() |
174 |
|
{ |
175 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
176 |
1 |
Assert.assertFalse("Wildcard action was equal!", event.equals(new ActionExecutingEvent())); |
177 |
|
} |
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
179 |
1 |
@Test... |
180 |
|
public void testDoesntEqualDifferentAction() |
181 |
|
{ |
182 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
183 |
1 |
Assert.assertFalse("A different action was equal!", event.equals(new ActionExecutingEvent("else"))); |
184 |
|
} |
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
186 |
1 |
@Test... |
187 |
|
public void testDoesntEqualDifferentCaseAction() |
188 |
|
{ |
189 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
190 |
1 |
Assert.assertFalse("Action equals comparison was case insensitive!", |
191 |
|
event.equals(new ActionExecutingEvent("SomeThing"))); |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
194 |
1 |
@Test... |
195 |
|
public void testDoesntEqualDifferentTypeOfAction() |
196 |
|
{ |
197 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
198 |
1 |
Assert.assertFalse("Same object isn't matched!", event.equals(new ActionExecutedEvent("something"))); |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
201 |
1 |
@Test... |
202 |
|
public void testWildcardActionDoesntEqualOtherActions() |
203 |
|
{ |
204 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
205 |
1 |
Assert.assertFalse("Wildcard action equals another action!", new ActionExecutingEvent().equals(event)); |
206 |
|
} |
207 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
208 |
1 |
@Test... |
209 |
|
public void testWildcardActionDoesntEqualEmptyAction() |
210 |
|
{ |
211 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent(""); |
212 |
1 |
Assert.assertFalse("Wildcard action equals another action!", new ActionExecutingEvent().equals(event)); |
213 |
|
} |
214 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
215 |
1 |
@Test... |
216 |
|
public void testWildcardActionEqualsWildcardAction() |
217 |
|
{ |
218 |
1 |
Assert.assertTrue("Wildcard action isn't equal to another wildcard action", |
219 |
|
new ActionExecutingEvent().equals(new ActionExecutingEvent())); |
220 |
|
} |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
222 |
1 |
@Test... |
223 |
|
public void testWildcardActionDoesntEqualNull() |
224 |
|
{ |
225 |
1 |
Assert.assertFalse("Wildcard action equals null!", new ActionExecutingEvent().equals(null)); |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
230 |
1 |
@Test... |
231 |
|
public void testHashCode() |
232 |
|
{ |
233 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent("something"); |
234 |
1 |
Assert.assertTrue("Hashcode was zero!", event.hashCode() != 0); |
235 |
|
} |
236 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
237 |
1 |
@Test... |
238 |
|
public void testHashCodeWithEmptyAction() |
239 |
|
{ |
240 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent(""); |
241 |
1 |
Assert.assertTrue("Hashcode for empty string action wasn't zero!", event.hashCode() == 0); |
242 |
|
} |
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
244 |
1 |
@Test... |
245 |
|
public void testHashCodeForWildcardAction() |
246 |
|
{ |
247 |
1 |
ActionExecutingEvent event = new ActionExecutingEvent(); |
248 |
1 |
Assert.assertTrue("Hashcode for wildcard action wasn't zero!", event.hashCode() == 0); |
249 |
|
} |
250 |
|
} |