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

File SpacePreferencesConfigurationSourceTest.java

 

Code metrics

0
8
4
1
70
36
4
0.5
2
4
1

Classes

Class Line # Actions
SpacePreferencesConfigurationSourceTest 36 8 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.configuration.internal;
21   
22    import static org.mockito.Mockito.when;
23   
24    import org.junit.Assert;
25    import org.junit.Test;
26    import org.xwiki.bridge.DocumentAccessBridge;
27    import org.xwiki.configuration.internal.test.AbstractTestDocumentConfigurationSource;
28    import org.xwiki.model.reference.DocumentReference;
29    import org.xwiki.model.reference.LocalDocumentReference;
30   
31    /**
32    * Unit tests for {@link SpacePreferencesConfigurationSource}.
33    *
34    * @version $Id: ca5d68d3a446dfb3347fdf3b93b2b0fdc2a8aad9 $
35    */
 
36    public class SpacePreferencesConfigurationSourceTest extends AbstractTestDocumentConfigurationSource
37    {
38    private static final DocumentReference SPACE_DOCUMENT = new DocumentReference(CURRENT_WIKI, "currentspace",
39    SpacePreferencesConfigurationSource.DOCUMENT_NAME);
40   
 
41  1 toggle public SpacePreferencesConfigurationSourceTest()
42    {
43  1 super(SpacePreferencesConfigurationSource.class);
44    }
45   
 
46  1 toggle @Override
47    public void before() throws Exception
48    {
49  1 super.before();
50   
51  1 DocumentAccessBridge documentAccessBridge = this.componentManager.getInstance(DocumentAccessBridge.class);
52  1 when(documentAccessBridge.getCurrentDocumentReference()).thenReturn(SPACE_DOCUMENT);
53    }
54   
 
55  3 toggle @Override
56    protected LocalDocumentReference getClassReference()
57    {
58  3 return SpacePreferencesConfigurationSource.CLASS_REFERENCE;
59    }
60   
 
61  1 toggle @Test
62    public void getPropertyForStringWhenExists() throws Exception
63    {
64  1 setStringProperty(SPACE_DOCUMENT, "key", "value");
65   
66  1 String result = this.componentManager.getComponentUnderTest().getProperty("key", String.class);
67   
68  1 Assert.assertEquals("value", result);
69    }
70    }