1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.tag

File TagParamUtilsTest.java

 

Code metrics

0
16
2
1
74
40
6
0.38
8
2
3

Classes

Class Line # Actions
TagParamUtilsTest 36 16 0% 6 4
0.777777877.8%
 

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   
21    package com.xpn.xwiki.plugin.tag;
22   
23    import org.hamcrest.Matchers;
24    import org.junit.Assert;
25    import org.junit.Test;
26   
27    import com.xpn.xwiki.XWikiException;
28   
29   
30    /**
31    * Unit tests for {@link TagParamUtils}.
32    *
33    * @version $Id: f5405a302930027f6d2525dc1702efb52152b26c $
34    * @since 8.2M1
35    */
 
36    public class TagParamUtilsTest
37    {
 
38  1 toggle @Test
39    public void spacesParameterToList() throws Exception
40    {
41  1 Assert.assertThat(TagParamUtils.spacesParameterToList("'Space1','Space2'"),
42    Matchers.contains("Space1", "Space2"));
43  1 Assert.assertThat(TagParamUtils.spacesParameterToList("'Space1', 'Space 2', 'Apo''strophe'"),
44    Matchers.contains("Space1", "Space 2", "Apo'strophe"));
45  1 Assert.assertThat(TagParamUtils.spacesParameterToList("'single space'"),
46    Matchers.contains("single space"));
47  1 Assert.assertThat(TagParamUtils.spacesParameterToList(""),
48    Matchers.empty());
49    }
50   
 
51  1 toggle @Test
52    public void spacesParameterToListExceptions() throws XWikiException
53    {
54  1 try {
55  1 TagParamUtils.spacesParameterToList(null);
56  0 Assert.fail("npe expected");
57    } catch (IllegalArgumentException expected) {}
58   
59  1 try {
60  1 TagParamUtils.spacesParameterToList("'space1','space2");
61  0 Assert.fail("XWikiException expected");
62    } catch (XWikiException expected) {}
63  1 try {
64  1 TagParamUtils.spacesParameterToList("'space1','space2',");
65  0 Assert.fail("XWikiException expected");
66    } catch (XWikiException expected) {}
67  1 try {
68  1 TagParamUtils.spacesParameterToList("'space1', or 'space2'");
69  0 Assert.fail("XWikiException expected");
70    } catch (XWikiException expected) {}
71    }
72   
73   
74    }