1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail.script; |
21 |
|
|
22 |
|
import javax.mail.Address; |
23 |
|
import javax.mail.Message; |
24 |
|
import javax.mail.internet.InternetAddress; |
25 |
|
|
26 |
|
import org.junit.Before; |
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.component.manager.ComponentManager; |
29 |
|
import org.xwiki.context.Execution; |
30 |
|
|
31 |
|
import static org.junit.Assert.assertArrayEquals; |
32 |
|
import static org.junit.Assert.assertEquals; |
33 |
|
import static org.mockito.Mockito.mock; |
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 6 |
Complexity Density: 0.4 |
|
41 |
|
public class ScriptMimeMessageTest |
42 |
|
{ |
43 |
|
private ScriptMimeMessage scriptMessage; |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
45 |
5 |
@Before... |
46 |
|
public void setUp() throws Exception |
47 |
|
{ |
48 |
5 |
Execution execution = mock(Execution.class); |
49 |
5 |
ComponentManager componentManager = mock(ComponentManager.class); |
50 |
|
|
51 |
5 |
this.scriptMessage = new ScriptMimeMessage(execution, componentManager); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void setSubject() throws Exception |
56 |
|
{ |
57 |
1 |
this.scriptMessage.setSubject("lorem ipsum"); |
58 |
1 |
assertEquals("lorem ipsum", this.scriptMessage.getSubject()); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
61 |
1 |
@Test... |
62 |
|
public void setFrom() throws Exception |
63 |
|
{ |
64 |
1 |
this.scriptMessage.setFrom(InternetAddress.parse("john@doe.com")[0]); |
65 |
1 |
assertArrayEquals(InternetAddress.parse("john@doe.com"), this.scriptMessage.getFrom()); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
68 |
1 |
@Test... |
69 |
|
public void addRecipients() throws Exception |
70 |
|
{ |
71 |
1 |
Address[] address = InternetAddress.parse("john@doe.com,jane@doe.com,jannie@doe.com"); |
72 |
1 |
this.scriptMessage.addRecipients(Message.RecipientType.TO, address); |
73 |
1 |
assertArrayEquals(address, this.scriptMessage.getRecipients(Message.RecipientType.TO)); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
76 |
1 |
@Test... |
77 |
|
public void addRecipient() throws Exception |
78 |
|
{ |
79 |
1 |
this.scriptMessage.addRecipient(Message.RecipientType.TO, InternetAddress.parse("john@doe.com")[0]); |
80 |
1 |
assertArrayEquals(InternetAddress.parse("john@doe.com"), |
81 |
|
this.scriptMessage.getRecipients(Message.RecipientType.TO)); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
84 |
1 |
@Test... |
85 |
|
public void addHeader() throws Exception |
86 |
|
{ |
87 |
1 |
String testHeader = "test"; |
88 |
|
|
89 |
1 |
this.scriptMessage.addHeader("X-Test", testHeader); |
90 |
|
|
91 |
1 |
assertEquals(testHeader, this.scriptMessage.getHeader("X-Test", null)); |
92 |
|
} |
93 |
|
} |