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

File EntityResourceReferenceTest.java

 

Code metrics

0
22
3
1
82
47
3
0.14
7.33
3
1

Classes

Class Line # Actions
EntityResourceReferenceTest 37 22 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.resource.entity;
21   
22    import java.util.Collections;
23    import java.util.Locale;
24   
25    import org.junit.*;
26    import org.xwiki.model.reference.DocumentReference;
27    import org.xwiki.model.reference.EntityReference;
28   
29    import static org.junit.Assert.*;
30   
31    /**
32    * Unit tests for {@link org.xwiki.resource.entity.EntityResourceReference}.
33    *
34    * @version $Id: 2379d62a1f5eb7956081f2dbba23377b7f68db65 $
35    * @since 6.1M2
36    */
 
37    public class EntityResourceReferenceTest
38    {
 
39  1 toggle @Test
40    public void creation()
41    {
42  1 EntityReference reference = new DocumentReference("wiki", "space", "page");
43  1 EntityResourceReference resource = new EntityResourceReference(reference, EntityResourceAction.VIEW);
44  1 assertEquals(EntityResourceAction.VIEW, resource.getAction());
45  1 assertEquals(reference, resource.getEntityReference());
46  1 assertEquals(Collections.EMPTY_MAP, resource.getParameters());
47  1 assertNull(resource.getLocale());
48   
49  1 resource.addParameter("param1", "value1");
50  1 assertEquals("value1", resource.getParameterValue("param1"));
51   
52  1 resource.setLocale(Locale.ROOT);
53  1 assertEquals(Locale.ROOT, resource.getLocale());
54   
55  1 resource.setRevision("1.0");
56  1 assertEquals("1.0", resource.getRevision());
57    }
58   
 
59  1 toggle @Test
60    public void identity()
61    {
62  1 EntityReference entityReference = new DocumentReference("wiki", "space", "page");
63  1 EntityResourceReference reference1 = new EntityResourceReference(entityReference, EntityResourceAction.VIEW);
64  1 EntityResourceReference reference2 = new EntityResourceReference(entityReference, EntityResourceAction.VIEW);
65  1 EntityResourceReference reference3 = new EntityResourceReference(entityReference,
66    new EntityResourceAction("other"));
67   
68  1 assertEquals(reference1.hashCode(), reference2.hashCode());
69  1 assertEquals(reference1, reference2);
70  1 assertNotEquals(reference1, reference3);
71    }
72   
 
73  1 toggle @Test
74    public void toStringTest()
75    {
76  1 EntityReference entityReference = new DocumentReference("wiki", "space", "page");
77  1 EntityResourceReference reference = new EntityResourceReference(entityReference, EntityResourceAction.VIEW);
78  1 assertEquals(
79    "type = [entity], parameters = [], reference = [wiki:space.page], action = [view], locale = [<null>]",
80    reference.toString());
81    }
82    }