1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.lesscss.internal.resources

File LESSObjectPropertyResourceReferenceTest.java

 

Code metrics

0
10
3
1
83
43
3
0.3
3.33
3
1

Classes

Class Line # Actions
LESSObjectPropertyResourceReferenceTest 41 10 0% 3 0
1.0100%
 

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    package org.xwiki.lesscss.internal.resources;
21   
22    import org.junit.Before;
23    import org.junit.Test;
24    import org.xwiki.bridge.DocumentAccessBridge;
25    import org.xwiki.model.reference.DocumentReference;
26    import org.xwiki.model.reference.EntityReferenceSerializer;
27    import org.xwiki.model.reference.ObjectPropertyReference;
28    import org.xwiki.model.reference.ObjectReference;
29   
30    import static org.junit.Assert.assertEquals;
31    import static org.mockito.ArgumentMatchers.eq;
32    import static org.mockito.Mockito.mock;
33    import static org.mockito.Mockito.when;
34   
35    /**
36    * Test class for {@link LESSObjectPropertyResourceReference}.
37    *
38    * @since 7.0RC1
39    * @version $Id: 2f5914da600219e943d2c54308495324e5791adf $
40    */
 
41    public class LESSObjectPropertyResourceReferenceTest
42    {
43    private EntityReferenceSerializer<String> entityReferenceSerializer;
44   
45    private DocumentAccessBridge bridge;
46   
 
47  2 toggle @Before
48    public void SetUp() throws Exception
49    {
50  2 entityReferenceSerializer = mock(EntityReferenceSerializer.class);
51  2 bridge = mock(DocumentAccessBridge.class);
52    }
53   
 
54  1 toggle @Test
55    public void getContent() throws Exception
56    {
57  1 ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property",
58    new ObjectReference("class", new DocumentReference("wiki", "Space", "Document")));
59  1 LESSObjectPropertyResourceReference lessObjectPropertyResourceReference
60    = new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge);
61   
62    // Mock
63  1 when(bridge.getProperty(eq(objectPropertyReference))).thenReturn("content");
64   
65    // Test
66  1 assertEquals("content", lessObjectPropertyResourceReference.getContent("skin"));
67    }
68   
 
69  1 toggle @Test
70    public void serialize() throws Exception
71    {
72  1 ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property",
73    new ObjectReference("class", new DocumentReference("wiki", "Space", "Document")));
74  1 LESSObjectPropertyResourceReference lessObjectPropertyResourceReference
75    = new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge);
76   
77    // Mock
78  1 when(entityReferenceSerializer.serialize(eq(objectPropertyReference))).thenReturn("objPropertyRef");
79   
80    // Test
81  1 assertEquals("LessXObjectProperty[objPropertyRef]", lessObjectPropertyResourceReference.serialize());
82    }
83    }