1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.observation.event; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.observation.event.filter.EventFilter; |
25 |
|
import org.xwiki.observation.event.filter.FixedNameEventFilter; |
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (68) |
Complexity: 5 |
Complexity Density: 0.08 |
|
27 |
|
public class CancelableEventTest |
28 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1.5 |
|
29 |
|
static class TestCancelableEvent extends AbstractCancelableEvent |
30 |
|
{ |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
31 |
5 |
public TestCancelableEvent()... |
32 |
|
{ |
33 |
|
|
34 |
|
} |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
36 |
16 |
public TestCancelableEvent(String name)... |
37 |
|
{ |
38 |
16 |
super(name); |
39 |
|
} |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
16 |
public TestCancelableEvent(EventFilter eventFilter)... |
42 |
|
{ |
43 |
16 |
super(eventFilter); |
44 |
|
} |
45 |
|
} |
46 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
47 |
|
static class TestCancelableEvent2 extends AbstractCancelableEvent |
48 |
|
{ |
49 |
|
|
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void testAbstractCancelableEvent() |
56 |
|
{ |
57 |
1 |
TestCancelableEvent event = new TestCancelableEvent(); |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
1 |
Assert.assertTrue(event.matches(event)); |
62 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent("name"))); |
63 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent(new FixedNameEventFilter("name2")))); |
64 |
|
|
65 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent2())); |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
1 |
Assert.assertTrue(event.equals(event)); |
70 |
1 |
Assert.assertTrue(event.equals(new TestCancelableEvent())); |
71 |
|
|
72 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent("name"))); |
73 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent(new FixedNameEventFilter("name")))); |
74 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent2())); |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
1 |
Assert.assertEquals(event.hashCode(), new TestCancelableEvent().hashCode()); |
79 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent2())); |
80 |
|
|
81 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent("name").hashCode()); |
82 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent(new FixedNameEventFilter("name")).hashCode()); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
85 |
1 |
@Test... |
86 |
|
public void testAbstractCancelableEventEventFilter() |
87 |
|
{ |
88 |
1 |
TestCancelableEvent event = new TestCancelableEvent(new FixedNameEventFilter("name")); |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
1 |
Assert.assertTrue(event.matches(event)); |
93 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent("name"))); |
94 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent(new FixedNameEventFilter("name")))); |
95 |
|
|
96 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent("name2"))); |
97 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent(new FixedNameEventFilter("name2")))); |
98 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent2())); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
1 |
Assert.assertTrue(event.equals(event)); |
103 |
1 |
Assert.assertTrue(event.equals(new TestCancelableEvent("name"))); |
104 |
1 |
Assert.assertTrue(event.equals(new TestCancelableEvent(new FixedNameEventFilter("name")))); |
105 |
|
|
106 |
1 |
Assert.assertFalse(event.equals(null)); |
107 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent("name2"))); |
108 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent(new FixedNameEventFilter("name2")))); |
109 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent2())); |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
1 |
Assert.assertEquals(event.hashCode(), new TestCancelableEvent("name").hashCode()); |
114 |
1 |
Assert.assertEquals(event.hashCode(), new TestCancelableEvent(new FixedNameEventFilter("name")).hashCode()); |
115 |
|
|
116 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent("name2").hashCode()); |
117 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent(new FixedNameEventFilter("name2")).hashCode()); |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
120 |
1 |
@Test... |
121 |
|
public void testAbstractCancelableEventString() |
122 |
|
{ |
123 |
1 |
TestCancelableEvent event = new TestCancelableEvent("name"); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
1 |
Assert.assertTrue(event.matches(event)); |
128 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent("name"))); |
129 |
1 |
Assert.assertTrue(event.matches(new TestCancelableEvent(new FixedNameEventFilter("name")))); |
130 |
|
|
131 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent("name2"))); |
132 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent(new FixedNameEventFilter("name2")))); |
133 |
1 |
Assert.assertFalse(event.matches(new TestCancelableEvent2())); |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
1 |
Assert.assertTrue(event.equals(event)); |
138 |
1 |
Assert.assertTrue(event.equals(new TestCancelableEvent("name"))); |
139 |
1 |
Assert.assertTrue(event.equals(new TestCancelableEvent(new FixedNameEventFilter("name")))); |
140 |
|
|
141 |
1 |
Assert.assertFalse(event.equals(null)); |
142 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent("name2"))); |
143 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent(new FixedNameEventFilter("name2")))); |
144 |
1 |
Assert.assertFalse(event.equals(new TestCancelableEvent2())); |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
1 |
Assert.assertEquals(event.hashCode(), new TestCancelableEvent("name").hashCode()); |
149 |
1 |
Assert.assertEquals(event.hashCode(), new TestCancelableEvent(new FixedNameEventFilter("name")).hashCode()); |
150 |
|
|
151 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent("name2").hashCode()); |
152 |
1 |
Assert.assertNotEquals(event.hashCode(), new TestCancelableEvent(new FixedNameEventFilter("name2")).hashCode()); |
153 |
|
} |
154 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
155 |
1 |
@Test... |
156 |
|
public void testCancel() |
157 |
|
{ |
158 |
1 |
CancelableEvent event = new TestCancelableEvent(); |
159 |
1 |
Assert.assertFalse(event.isCanceled()); |
160 |
1 |
Assert.assertNull(event.getReason()); |
161 |
1 |
event.cancel(); |
162 |
1 |
Assert.assertTrue(event.isCanceled()); |
163 |
1 |
Assert.assertNull(event.getReason()); |
164 |
|
} |
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
166 |
1 |
@Test... |
167 |
|
public void testCancelWithReason() |
168 |
|
{ |
169 |
1 |
String reason = "Tralala"; |
170 |
1 |
CancelableEvent event = new TestCancelableEvent(); |
171 |
1 |
Assert.assertFalse(event.isCanceled()); |
172 |
1 |
Assert.assertNull(event.getReason()); |
173 |
1 |
event.cancel(reason); |
174 |
1 |
Assert.assertTrue(event.isCanceled()); |
175 |
1 |
Assert.assertEquals(reason, event.getReason()); |
176 |
|
} |
177 |
|
} |