1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.properties.internal.converter; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.properties.ConverterManager; |
26 |
|
import org.xwiki.properties.converter.ConversionException; |
27 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
28 |
|
|
29 |
|
|
30 |
|
@link |
31 |
|
|
32 |
|
@version |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 6 |
Complexity Density: 0.86 |
|
34 |
|
public class EnumConverterTest extends AbstractComponentTestCase |
35 |
|
{ |
36 |
|
private ConverterManager converterManager; |
37 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
38 |
|
public enum EnumTest |
39 |
|
{ |
40 |
|
VALUE1, |
41 |
|
Value2 |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
5 |
@Before... |
45 |
|
@Override |
46 |
|
public void setUp() throws Exception |
47 |
|
{ |
48 |
5 |
super.setUp(); |
49 |
|
|
50 |
5 |
this.converterManager = getComponentManager().getInstance(ConverterManager.class); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testConvertValid() |
55 |
|
{ |
56 |
1 |
Assert.assertEquals(EnumTest.VALUE1, this.converterManager.convert(EnumTest.class, "VALUE1")); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void testConvertIgnireCase() |
61 |
|
{ |
62 |
1 |
Assert.assertEquals(EnumTest.VALUE1, this.converterManager.convert(EnumTest.class, "value1")); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testConvertToString() |
67 |
|
{ |
68 |
1 |
Assert.assertEquals("VALUE1", this.converterManager.convert(String.class, EnumTest.VALUE1)); |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
71 |
1 |
@Test(expected = ConversionException.class)... |
72 |
|
public void testConvertInvalid() |
73 |
|
{ |
74 |
1 |
this.converterManager.convert(EnumTest.class, "notexistingvalue"); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
public void testConvertNull() |
79 |
|
{ |
80 |
1 |
Assert.assertNull(this.converterManager.convert(EnumTest.class, null)); |
81 |
|
} |
82 |
|
} |