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 (76) |
Complexity: 26 |
Complexity Density: 0.52 |
|
33 |
|
public class ActionExecutedEventTest |
34 |
|
{ |
35 |
|
|
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
37 |
1 |
@Test... |
38 |
|
public void testDefaultConstructor() |
39 |
|
{ |
40 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent(); |
41 |
1 |
Assert.assertNull("A default action was used!", event.getActionName()); |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
44 |
1 |
@Test... |
45 |
|
public void testConstructorWithActionName() |
46 |
|
{ |
47 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
48 |
1 |
Assert.assertEquals("Action name was lost!", "something", event.getActionName()); |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testMatchesSameObject() |
55 |
|
{ |
56 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
57 |
1 |
Assert.assertTrue("Same object wasn't matched!", event.matches(event)); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testMatchesSameAction() |
62 |
|
{ |
63 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
64 |
1 |
Assert.assertTrue("Same action wasn't matched!", event.matches(new ActionExecutedEvent("something"))); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
67 |
1 |
@Test... |
68 |
|
public void testDoesntMatchNull() |
69 |
|
{ |
70 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
71 |
1 |
Assert.assertFalse("null was matched!", event.matches(null)); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
74 |
1 |
@Test... |
75 |
|
public void testDoesntMatchWildcardAction() |
76 |
|
{ |
77 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
78 |
1 |
Assert.assertFalse("Wildcard action was matched!", event.matches(new ActionExecutedEvent())); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testDoesntMatchDifferentAction() |
83 |
|
{ |
84 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
85 |
1 |
Assert.assertFalse("A different action was matched!", event.matches(new ActionExecutedEvent("else"))); |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
88 |
1 |
@Test... |
89 |
|
public void testDoesntMatchDifferentCaseAction() |
90 |
|
{ |
91 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
92 |
1 |
Assert.assertFalse("Action matching was case insensitive!", |
93 |
|
event.matches(new ActionExecutedEvent("SomeThing"))); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
96 |
1 |
@Test... |
97 |
|
public void testDoesntMatchDifferentTypeOfAction() |
98 |
|
{ |
99 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
100 |
1 |
Assert.assertFalse("A different type of action was matched!", |
101 |
|
event.matches(new ActionExecutingEvent("something"))); |
102 |
|
} |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
104 |
1 |
@Test... |
105 |
|
public void testWildcardActionMatchesAll() |
106 |
|
{ |
107 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
108 |
1 |
Assert.assertTrue("Wildcard action didn't match!", new ActionExecutedEvent().matches(event)); |
109 |
1 |
Assert.assertTrue("Wildcard action didn't match another wildcard action!", |
110 |
|
new ActionExecutedEvent().matches(new ActionExecutedEvent())); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
113 |
1 |
@Test... |
114 |
|
public void testWildcardActionDoesnMatchNull() |
115 |
|
{ |
116 |
1 |
Assert.assertFalse("Wildcard action matched null!", new ActionExecutedEvent().matches(null)); |
117 |
|
} |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
119 |
1 |
@Test... |
120 |
|
public void testEmptyActionDoesntMatch() |
121 |
|
{ |
122 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
123 |
1 |
Assert.assertFalse("Empty action behaves as wildcard!", new ActionExecutedEvent("").matches(event)); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
128 |
1 |
@Test... |
129 |
|
public void testEqualsSameObject() |
130 |
|
{ |
131 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
132 |
1 |
Assert.assertTrue("Same object wasn't equal!", event.equals(event)); |
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
135 |
1 |
@Test... |
136 |
|
public void testEqualsSameAction() |
137 |
|
{ |
138 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
139 |
1 |
Assert.assertTrue("Same action wasn't equal!", event.equals(new ActionExecutedEvent("something"))); |
140 |
|
} |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
142 |
1 |
@Test... |
143 |
|
public void testEqualsWithNull() |
144 |
|
{ |
145 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
146 |
1 |
Assert.assertFalse("null was equal!", event.equals(null)); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
149 |
1 |
@Test... |
150 |
|
public void testDoesntEqualWildcardAction() |
151 |
|
{ |
152 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
153 |
1 |
Assert.assertFalse("Wildcard action was equal!", event.equals(new ActionExecutedEvent())); |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
156 |
1 |
@Test... |
157 |
|
public void testDoesntEqualDifferentAction() |
158 |
|
{ |
159 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
160 |
1 |
Assert.assertFalse("A different action was equal!", event.equals(new ActionExecutedEvent("else"))); |
161 |
|
} |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
163 |
1 |
@Test... |
164 |
|
public void testDoesntEqualDifferentCaseAction() |
165 |
|
{ |
166 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
167 |
1 |
Assert.assertFalse("Action equals comparison was case insensitive!", |
168 |
|
event.equals(new ActionExecutedEvent("SomeThing"))); |
169 |
|
} |
170 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
171 |
1 |
@Test... |
172 |
|
public void testDoesntEqualDifferentTypeOfAction() |
173 |
|
{ |
174 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
175 |
1 |
Assert.assertFalse("Same object isn't matched!", event.equals(new ActionExecutingEvent("something"))); |
176 |
|
} |
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
178 |
1 |
@Test... |
179 |
|
public void testWildcardActionDoesntEqualOtherActions() |
180 |
|
{ |
181 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
182 |
1 |
Assert.assertFalse("Wildcard action equals another action!", new ActionExecutedEvent().equals(event)); |
183 |
|
} |
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
185 |
1 |
@Test... |
186 |
|
public void testWildcardActionDoesntEqualEmptyAction() |
187 |
|
{ |
188 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent(""); |
189 |
1 |
Assert.assertFalse("Wildcard action equals another action!", new ActionExecutedEvent().equals(event)); |
190 |
|
} |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
192 |
1 |
@Test... |
193 |
|
public void testWildcardActionEqualsWildcardAction() |
194 |
|
{ |
195 |
1 |
Assert.assertTrue("Wildcard action isn't equal to another wildcard action", |
196 |
|
new ActionExecutedEvent().equals(new ActionExecutedEvent())); |
197 |
|
} |
198 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
199 |
1 |
@Test... |
200 |
|
public void testWildcardActionDoesntEqualNull() |
201 |
|
{ |
202 |
1 |
Assert.assertFalse("Wildcard action equals null!", new ActionExecutedEvent().equals(null)); |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
207 |
1 |
@Test... |
208 |
|
public void testHashCode() |
209 |
|
{ |
210 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent("something"); |
211 |
1 |
Assert.assertTrue("Hashcode was zero!", event.hashCode() != 0); |
212 |
|
} |
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
214 |
1 |
@Test... |
215 |
|
public void testHashCodeWithEmptyAction() |
216 |
|
{ |
217 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent(""); |
218 |
1 |
Assert.assertTrue("Hashcode for empty string action wasn't zero!", event.hashCode() == 0); |
219 |
|
} |
220 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
221 |
1 |
@Test... |
222 |
|
public void testHashCodeForWildcardAction() |
223 |
|
{ |
224 |
1 |
ActionExecutedEvent event = new ActionExecutedEvent(); |
225 |
1 |
Assert.assertTrue("Hashcode for wildcard action wasn't zero!", event.hashCode() == 0); |
226 |
|
} |
227 |
|
} |