1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.listener.chaining; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import org.junit.Assert; |
26 |
|
import org.junit.Before; |
27 |
|
import org.junit.Test; |
28 |
|
|
29 |
|
|
30 |
|
@link |
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 7 |
Complexity Density: 0.44 |
|
35 |
|
public class EmptyBlockChainingListenerTest |
36 |
|
{ |
37 |
|
private ListenerChain chain; |
38 |
|
|
39 |
|
private EmptyBlockChainingListener listener; |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
41 |
2 |
@Before... |
42 |
|
public void setUp() |
43 |
|
{ |
44 |
2 |
this.chain = new ListenerChain(); |
45 |
2 |
this.listener = new EmptyBlockChainingListener(this.chain); |
46 |
2 |
this.chain.addListener(this.listener); |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void testEmptyParagraphContainer() |
54 |
|
{ |
55 |
1 |
this.chain.addListener(new AbstractChainingListener() |
56 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
1 |
{... |
58 |
1 |
setListenerChain(EmptyBlockChainingListenerTest.this.chain); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
1 |
@Override... |
62 |
|
public void endParagraph(Map<String, String> parameters) |
63 |
|
{ |
64 |
1 |
EmptyBlockChainingListener blockState = |
65 |
|
(EmptyBlockChainingListener) getListenerChain().getListener(EmptyBlockChainingListener.class); |
66 |
1 |
Assert.assertTrue(blockState.isCurrentContainerBlockEmpty()); |
67 |
|
} |
68 |
|
}); |
69 |
|
|
70 |
1 |
this.listener.beginParagraph(Collections.<String, String>emptyMap()); |
71 |
1 |
this.listener.endParagraph(Collections.<String, String>emptyMap()); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
public void testNonEmptyParagraphContainer() |
79 |
|
{ |
80 |
1 |
this.chain.addListener(new AbstractChainingListener() |
81 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
1 |
{... |
83 |
1 |
setListenerChain(EmptyBlockChainingListenerTest.this.chain); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
86 |
1 |
@Override... |
87 |
|
public void endParagraph(Map<String, String> parameters) |
88 |
|
{ |
89 |
1 |
EmptyBlockChainingListener blockState = |
90 |
|
(EmptyBlockChainingListener) getListenerChain().getListener(EmptyBlockChainingListener.class); |
91 |
1 |
Assert.assertFalse(blockState.isCurrentContainerBlockEmpty()); |
92 |
|
} |
93 |
|
}); |
94 |
|
|
95 |
1 |
this.listener.beginParagraph(Collections.<String, String>emptyMap()); |
96 |
1 |
this.listener.onWord("word"); |
97 |
1 |
this.listener.endParagraph(Collections.<String, String>emptyMap()); |
98 |
|
} |
99 |
|
} |