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

File DefaultConverterManagerTest.java

 

Code metrics

0
5
5
2
80
47
5
1
1
2.5
1

Classes

Class Line # Actions
DefaultConverterManagerTest 39 5 0% 5 0
1.0100%
DefaultConverterManagerTest.TestEnum 45 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 5 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.properties.internal;
21   
22    import java.awt.Color;
23   
24    import org.junit.Assert;
25    import org.junit.Rule;
26    import org.junit.Test;
27    import org.xwiki.component.manager.ComponentLookupException;
28    import org.xwiki.properties.ConverterManager;
29    import org.xwiki.properties.converter.ConversionException;
30    import org.xwiki.test.annotation.AllComponents;
31    import org.xwiki.test.mockito.MockitoComponentMockingRule;
32   
33    /**
34    * Validate {@link DefaultConverterManager}.
35    *
36    * @version $Id: b75df3e29156b7d58d75a2919e70bada9fbf518c $
37    */
38    @AllComponents
 
39    public class DefaultConverterManagerTest
40    {
41    @Rule
42    public MockitoComponentMockingRule<ConverterManager> mocker = new MockitoComponentMockingRule<ConverterManager>(
43    DefaultConverterManager.class);
44   
 
45    public enum TestEnum
46    {
47    ENUMVALUE
48    }
49   
 
50  1 toggle @Test
51    public void testConvert() throws ComponentLookupException
52    {
53  1 Assert.assertEquals(Integer.valueOf(42), this.mocker.getComponentUnderTest().convert(Integer.class, "42"));
54    }
55   
 
56  1 toggle @Test
57    public void testConvertEnum() throws ComponentLookupException
58    {
59  1 Assert.assertEquals(TestEnum.ENUMVALUE, this.mocker.getComponentUnderTest()
60    .convert(TestEnum.class, "ENUMVALUE"));
61    }
62   
 
63  1 toggle @Test
64    public void testConvertColor() throws ComponentLookupException
65    {
66  1 Assert.assertEquals(Color.WHITE, this.mocker.getComponentUnderTest().convert(Color.class, "#ffffff"));
67    }
68   
 
69  1 toggle @Test(expected = ConversionException.class)
70    public void testConvertUnsupportedType() throws ComponentLookupException
71    {
72  1 this.mocker.getComponentUnderTest().convert(DefaultConverterManagerTest.class, "#ffffff");
73    }
74   
 
75  1 toggle @Test
76    public void testConvertSame() throws ComponentLookupException
77    {
78  1 Assert.assertSame(Color.WHITE, this.mocker.getComponentUnderTest().convert(Color.class, Color.WHITE));
79    }
80    }