1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.refactoring.splitter.criterion; |
21 |
|
|
22 |
|
import java.io.StringReader; |
23 |
|
|
24 |
|
import org.xwiki.refactoring.internal.AbstractRefactoringTestCase; |
25 |
|
import org.xwiki.rendering.block.Block; |
26 |
|
import org.xwiki.rendering.block.XDOM; |
27 |
|
import org.junit.Assert; |
28 |
|
import org.junit.Test; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
36 |
|
public class HeadingLevelSplittingCriterionTest extends AbstractRefactoringTestCase |
37 |
|
{ |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@throws |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
43 |
1 |
@Test... |
44 |
|
public void testIterateCondition() throws Exception |
45 |
|
{ |
46 |
1 |
XDOM xdom = xwikiParser.parse(new StringReader("=Test=")); |
47 |
1 |
SplittingCriterion splittingCriterion = new HeadingLevelSplittingCriterion(new int[] {3, 2, 1}); |
48 |
1 |
Block sectionBlock = xdom.getChildren().get(0); |
49 |
1 |
Assert.assertTrue(!splittingCriterion.shouldIterate(xdom, 0)); |
50 |
1 |
Assert.assertTrue(splittingCriterion.shouldIterate(sectionBlock, 1)); |
51 |
1 |
Assert.assertTrue(splittingCriterion.shouldSplit(sectionBlock, 3)); |
52 |
1 |
Assert.assertTrue(!splittingCriterion.shouldSplit(sectionBlock, 4)); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@throws |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testSplitCondition() throws Exception |
62 |
|
{ |
63 |
1 |
XDOM xdom = xwikiParser.parse(new StringReader("=Test=")); |
64 |
1 |
SplittingCriterion splittingCriterion = new HeadingLevelSplittingCriterion(new int[] {3, 2, 1}); |
65 |
1 |
Block sectionBlock = xdom.getChildren().get(0); |
66 |
1 |
Assert.assertTrue(splittingCriterion.shouldSplit(sectionBlock, 1)); |
67 |
1 |
splittingCriterion = new HeadingLevelSplittingCriterion(new int[] {3, 2}); |
68 |
1 |
Assert.assertTrue(!splittingCriterion.shouldSplit(sectionBlock, 1)); |
69 |
|
} |
70 |
|
} |