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.Message; |
23 |
|
import javax.mail.internet.MimeMessage; |
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: 4 |
Complexity Density: 0.4 |
|
38 |
|
public class RecipientConverterTest |
39 |
|
{ |
40 |
|
@Rule |
41 |
|
public MockitoComponentMockingRule<RecipientConverter> mocker = |
42 |
|
new MockitoComponentMockingRule<>(RecipientConverter.class); |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
44 |
1 |
@Test... |
45 |
|
public void convert() throws Exception |
46 |
|
{ |
47 |
1 |
assertEquals(Message.RecipientType.TO, |
48 |
|
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, "to")); |
49 |
1 |
assertEquals("To", |
50 |
|
this.mocker.getComponentUnderTest().convert(String.class, Message.RecipientType.TO)); |
51 |
|
|
52 |
1 |
assertEquals(Message.RecipientType.CC, |
53 |
|
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, "cc")); |
54 |
1 |
assertEquals(Message.RecipientType.BCC, |
55 |
|
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, "bcc")); |
56 |
1 |
assertEquals(MimeMessage.RecipientType.NEWSGROUPS, |
57 |
|
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, "newsgroups")); |
58 |
|
} |
59 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void convertWhenInvalidType() throws Exception |
62 |
|
{ |
63 |
1 |
try { |
64 |
1 |
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, "something"); |
65 |
0 |
fail("Should have thrown an exception here"); |
66 |
|
} catch (ConversionException expected) { |
67 |
1 |
assertEquals("Cannot convert [something] to [javax.mail.Message$RecipientType]", expected.getMessage()); |
68 |
|
} |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
71 |
1 |
@Test... |
72 |
|
public void convertWhenTypeIsAlreadyARecipientType() throws Exception |
73 |
|
{ |
74 |
1 |
assertEquals(Message.RecipientType.TO, |
75 |
|
this.mocker.getComponentUnderTest().convert(Message.RecipientType.class, Message.RecipientType.TO)); |
76 |
|
} |
77 |
|
} |