1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.listener.reference

File ResourceReferenceTest.java

 

Code metrics

0
24
3
1
79
45
3
0.12
8
3
1

Classes

Class Line # Actions
ResourceReferenceTest 31 24 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: 793f29d7b950f3ae1de4846ec23390afbf6d50cc $
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  1 Assert.assertFalse(reference1.equals(null));
61  1 Assert.assertFalse(reference1.equals("different object class"));
62   
63  1 reference1.addBaseReference("base");
64  1 Assert.assertEquals(reference1, reference2);
65  1 Assert.assertEquals(reference1, reference1);
66    }
67   
 
68  1 toggle @Test
69    public void testHashCode()
70    {
71  1 ResourceReference reference1 = new ResourceReference("reference", ResourceType.DOCUMENT);
72  1 ResourceReference reference2 = new ResourceReference("reference", ResourceType.DOCUMENT);
73  1 Assert.assertEquals(reference1.hashCode(), reference2.hashCode());
74   
75  1 reference1.addBaseReference("base");
76  1 reference2.addBaseReference("base");
77  1 Assert.assertEquals(reference1.hashCode(), reference2.hashCode());
78    }
79    }