1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.model.reference

File SpaceReferenceTest.java

 

Code metrics

0
12
3
1
69
39
6
0.5
4
3
2

Classes

Class Line # Actions
SpaceReferenceTest 33 12 0% 6 3
0.880%
 

Contributing tests

This file is covered by 3 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.model.reference;
21   
22    import org.junit.Test;
23    import org.xwiki.model.EntityType;
24   
25    import org.junit.Assert;
26   
27    /**
28    * Unit tests for {@link org.xwiki.model.reference.SpaceReference}.
29    *
30    * @version $Id: 1a165eb6c5826cba4001371da5fd63608623dfb0 $
31    * @since 2.2M1
32    */
 
33    public class SpaceReferenceTest
34    {
 
35  1 toggle @Test
36    public void testInvalidType()
37    {
38  1 try {
39  1 new SpaceReference(new EntityReference("space", EntityType.WIKI));
40  0 Assert.fail("Should have thrown an exception here");
41    } catch (IllegalArgumentException expected) {
42  1 Assert.assertEquals("Invalid type [WIKI] for a space reference", expected.getMessage());
43    }
44    }
45   
 
46  1 toggle @Test
47    public void testInvalidNullParent()
48    {
49  1 try {
50  1 new SpaceReference("page", (WikiReference) null);
51  0 Assert.fail("Should have thrown an exception here");
52    } catch (IllegalArgumentException expected) {
53  1 Assert.assertEquals("Invalid parent reference [null] in a space reference", expected.getMessage());
54    }
55    }
56   
 
57  1 toggle @Test
58    public void testInvalidParentType()
59    {
60  1 try {
61  1 new SpaceReference(new EntityReference("space", EntityType.SPACE,
62    new EntityReference("whatever", EntityType.DOCUMENT, null)));
63  0 Assert.fail("Should have thrown an exception here");
64    } catch (IllegalArgumentException expected) {
65  1 Assert.assertEquals("Invalid parent reference [Document whatever] in a space reference",
66    expected.getMessage());
67    }
68    }
69    }