1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.component.event; |
21 |
|
|
22 |
|
import java.lang.reflect.Type; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.observation.event.Event; |
27 |
|
|
28 |
|
|
29 |
|
@link |
30 |
|
|
31 |
|
@version |
32 |
|
|
|
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 6 |
Complexity Density: 0.43 |
|
33 |
|
public class ComponentDescriptorAddedEventTest |
34 |
|
{ |
35 |
|
|
36 |
|
|
37 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
38 |
|
private static class Dummy |
39 |
|
{ |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void testMatchesAllComponentRoles() |
44 |
|
{ |
45 |
1 |
ComponentDescriptorAddedEvent event = new ComponentDescriptorAddedEvent(); |
46 |
|
|
47 |
1 |
Assert.assertTrue(event.matches(new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint"))); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void testMatchesWhenDifferentEvent() |
52 |
|
{ |
53 |
1 |
ComponentDescriptorAddedEvent event = new ComponentDescriptorAddedEvent(); |
54 |
1 |
Assert.assertFalse(event.matches(new Event() |
55 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
0 |
@Override... |
57 |
|
public boolean matches(Object otherEvent) |
58 |
|
{ |
59 |
0 |
return false; |
60 |
|
} |
61 |
|
})); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void testMatchesWhenSpecificRoleSpecified() |
66 |
|
{ |
67 |
|
|
68 |
1 |
ComponentDescriptorAddedEvent event = new ComponentDescriptorAddedEvent((Type) Dummy.class); |
69 |
1 |
Assert.assertTrue(event.matches(new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint"))); |
70 |
|
|
71 |
1 |
Assert.assertFalse(event.matches(new ComponentDescriptorAddedEvent((Type) ComponentDescriptorAddedEvent.class, |
72 |
|
"rolehint"))); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void testEquals() |
77 |
|
{ |
78 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent(), new ComponentDescriptorAddedEvent()); |
79 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent((Type) Dummy.class), new ComponentDescriptorAddedEvent( |
80 |
|
(Type) Dummy.class)); |
81 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint"), |
82 |
|
new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint")); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
85 |
1 |
@Test... |
86 |
|
public void testHashCode() |
87 |
|
{ |
88 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent().hashCode(), |
89 |
|
new ComponentDescriptorAddedEvent().hashCode()); |
90 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent((Type) Dummy.class).hashCode(), |
91 |
|
new ComponentDescriptorAddedEvent((Type) Dummy.class).hashCode()); |
92 |
1 |
Assert.assertEquals(new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint").hashCode(), |
93 |
|
new ComponentDescriptorAddedEvent((Type) Dummy.class, "rolehint").hashCode()); |
94 |
|
} |
95 |
|
} |