1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail.internal; |
21 |
|
|
22 |
|
import javax.mail.Address; |
23 |
|
import javax.mail.internet.InternetAddress; |
24 |
|
|
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.properties.converter.ConversionException; |
28 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
29 |
|
|
30 |
|
import static org.junit.Assert.*; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 5 |
Complexity Density: 0.56 |
|
38 |
|
public class AddressConverterTest |
39 |
|
{ |
40 |
|
@Rule |
41 |
|
public MockitoComponentMockingRule<AddressConverter> mocker = |
42 |
|
new MockitoComponentMockingRule<>(AddressConverter.class); |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
44 |
1 |
@Test... |
45 |
|
public void convert() throws Exception |
46 |
|
{ |
47 |
1 |
InternetAddress address = new InternetAddress("John Doe(comment) <john1@doe.com>"); |
48 |
1 |
assertEquals(address, |
49 |
|
this.mocker.getComponentUnderTest().convert(Address.class, "John Doe(comment) <john1@doe.com>")); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void convertWhenNull() throws Exception |
54 |
|
{ |
55 |
1 |
assertNull(this.mocker.getComponentUnderTest().convert(Address.class, null)); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
58 |
1 |
@Test... |
59 |
|
public void convertWhenTypeIsAlreadyAnAddress() throws Exception |
60 |
|
{ |
61 |
1 |
InternetAddress address = new InternetAddress("John Doe(comment) <john1@doe.com>"); |
62 |
1 |
assertEquals(address, this.mocker.getComponentUnderTest().convert(Address.class, address)); |
63 |
|
} |
64 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void convertWhenInvalid() throws Exception |
67 |
|
{ |
68 |
1 |
try { |
69 |
1 |
this.mocker.getComponentUnderTest().convert(Address.class, "invalid("); |
70 |
0 |
fail("Should have thrown an exception here"); |
71 |
|
} catch (ConversionException expected) { |
72 |
1 |
assertEquals("Failed to convert [invalid(] to [javax.mail.Address]", expected.getMessage()); |
73 |
|
} |
74 |
|
} |
75 |
|
} |