1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.refactoring.splitter.criterion

File HeadingLevelSplittingCriterionTest.java

 

Code metrics

0
13
2
1
70
31
2
0.15
6.5
2
1

Classes

Class Line # Actions
HeadingLevelSplittingCriterionTest 36 13 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Test class for {@link HeadingLevelSplittingCriterion}.
32    *
33    * @version $Id: 6db550c328b6c3831efb6fd61f222ed1c7454194 $
34    * @since 1.9M1
35    */
 
36    public class HeadingLevelSplittingCriterionTest extends AbstractRefactoringTestCase
37    {
38    /**
39    * Tests the iterate condition.
40    *
41    * @throws Exception
42    */
 
43  1 toggle @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    * Tests the split condition.
57    *
58    * @throws Exception
59    */
 
60  1 toggle @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    }