1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.block; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.properties.converter.ConversionException; |
25 |
|
import org.xwiki.rendering.block.SpaceBlock; |
26 |
|
import org.xwiki.rendering.block.WordBlock; |
27 |
|
import org.xwiki.rendering.block.match.BlockMatcher; |
28 |
|
import org.xwiki.rendering.block.match.ClassBlockMatcher; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 4 |
Complexity Density: 0.31 |
|
36 |
|
public class BlockMatcherConverterTest |
37 |
|
{ |
38 |
|
private BlockMatcherConverter converter = new BlockMatcherConverter(); |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
40 |
1 |
@Test... |
41 |
|
public void testConvertFromString() |
42 |
|
{ |
43 |
1 |
BlockMatcher wordMatcher = |
44 |
|
this.converter.convert(BlockMatcher.class, "class:org.xwiki.rendering.block.WordBlock"); |
45 |
1 |
Assert.assertTrue(wordMatcher instanceof ClassBlockMatcher); |
46 |
|
|
47 |
1 |
Assert.assertTrue(wordMatcher.match(new WordBlock("test"))); |
48 |
1 |
Assert.assertFalse(wordMatcher.match(new SpaceBlock())); |
49 |
|
|
50 |
1 |
BlockMatcher wordMatcher2 = this.converter.convert(BlockMatcher.class, "class:WordBlock"); |
51 |
1 |
Assert.assertTrue(wordMatcher2 instanceof ClassBlockMatcher); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void testConvertFromStringFailures() |
56 |
|
{ |
57 |
1 |
assertConversionException("class:does.not.exist.FantasyBlock"); |
58 |
1 |
assertConversionException("class:java.lang.String"); |
59 |
1 |
assertConversionException("class:FantasyBlock"); |
60 |
1 |
assertConversionException("macro:box"); |
61 |
|
} |
62 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
63 |
4 |
private void assertConversionException(String input)... |
64 |
|
{ |
65 |
4 |
try { |
66 |
4 |
this.converter.convert(BlockMatcher.class, input); |
67 |
0 |
Assert.fail("should not parse " + input); |
68 |
|
} catch (ConversionException e) { |
69 |
|
|
70 |
|
} |
71 |
|
} |
72 |
|
} |