1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.block.match

File OrBlockMatcherTest.java

 

Code metrics

0
8
2
1
64
33
2
0.25
4
2
1

Classes

Class Line # Actions
OrBlockMatcherTest 39 8 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.rendering.block.match;
21   
22    import java.util.Arrays;
23    import java.util.Collections;
24   
25    import org.junit.Assert;
26    import org.junit.Test;
27    import org.xwiki.rendering.block.Block;
28    import org.xwiki.rendering.block.FormatBlock;
29    import org.xwiki.rendering.block.GroupBlock;
30    import org.xwiki.rendering.block.WordBlock;
31    import org.xwiki.rendering.listener.Format;
32   
33    /**
34    * Unit tests for {@link OrBlockMatcher}.
35    *
36    * @version $Id: f8b655370adda8123d37e4c3134ec08c6c2b0505 $
37    * @since 4.3M2
38    */
 
39    public class OrBlockMatcherTest
40    {
 
41  1 toggle @Test
42    public void matchWhenUsingVarargConstructor()
43    {
44  1 OrBlockMatcher matcher = new OrBlockMatcher(
45    new ClassBlockMatcher(GroupBlock.class),
46    new ClassBlockMatcher(FormatBlock.class));
47   
48  1 Assert.assertTrue(matcher.match(new GroupBlock()));
49  1 Assert.assertTrue(matcher.match(new FormatBlock(Collections.<Block>emptyList(), Format.BOLD)));
50  1 Assert.assertFalse(matcher.match(new WordBlock("test")));
51    }
52   
 
53  1 toggle @Test
54    public void matchWhenUsingListConstructor()
55    {
56  1 OrBlockMatcher matcher = new OrBlockMatcher(Arrays.<BlockMatcher>asList(
57    new ClassBlockMatcher(GroupBlock.class),
58    new ClassBlockMatcher(FormatBlock.class)));
59   
60  1 Assert.assertTrue(matcher.match(new GroupBlock()));
61  1 Assert.assertTrue(matcher.match(new FormatBlock(Collections.<Block>emptyList(), Format.BOLD)));
62  1 Assert.assertFalse(matcher.match(new WordBlock("test")));
63    }
64    }