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

File ResourceReferenceTest.java

 

Code metrics

0
21
3
1
76
42
3
0.14
7
3
1

Classes

Class Line # Actions
ResourceReferenceTest 31 21 0% 3 0
1.0100%
 

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.rendering.listener.reference;
21   
22    import org.junit.Assert;
23    import org.junit.Test;
24   
25    /**
26    * Unit tests for {@link ResourceReference}.
27    *
28    * @version $Id: acf4e4dc19ba7165f56011279dfaaf4369edacd8 $
29    * @since 3.0M2
30    */
 
31    public class ResourceReferenceTest
32    {
 
33  1 toggle @Test
34    public void testToString()
35    {
36  1 ResourceReference reference = new ResourceReference("reference", ResourceType.DOCUMENT);
37  1 Assert.assertEquals("Typed = [true] Type = [doc] Reference = [reference]", reference.toString());
38   
39  1 reference.addBaseReference("baseref1");
40  1 reference.addBaseReference("baseref2");
41  1 Assert.assertEquals("Typed = [true] Type = [doc] Reference = [reference] "
42    + "Base References = [[baseref1], [baseref2]]", reference.toString());
43   
44  1 reference.setParameter("name1", "value1");
45  1 reference.setParameter("name2", "value2");
46  1 Assert.assertEquals("Typed = [true] Type = [doc] Reference = [reference] "
47    + "Base References = [[baseref1], [baseref2]] "
48    + "Parameters = [[name1] = [value1], [name2] = [value2]]", reference.toString());
49    }
50   
 
51  1 toggle @Test
52    public void testEquals()
53    {
54  1 ResourceReference reference1 = new ResourceReference("reference", ResourceType.DOCUMENT);
55  1 ResourceReference reference2 = new ResourceReference("reference", ResourceType.DOCUMENT);
56  1 Assert.assertEquals(reference1, reference2);
57   
58  1 reference2.addBaseReference("base");
59  1 Assert.assertFalse(reference1.equals(reference2));
60   
61  1 reference1.addBaseReference("base");
62  1 Assert.assertEquals(reference1, reference2);
63    }
64   
 
65  1 toggle @Test
66    public void testHashCode()
67    {
68  1 ResourceReference reference1 = new ResourceReference("reference", ResourceType.DOCUMENT);
69  1 ResourceReference reference2 = new ResourceReference("reference", ResourceType.DOCUMENT);
70  1 Assert.assertEquals(reference1.hashCode(), reference2.hashCode());
71   
72  1 reference1.addBaseReference("base");
73  1 reference2.addBaseReference("base");
74  1 Assert.assertEquals(reference1.hashCode(), reference2.hashCode());
75    }
76    }