1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail; |
21 |
|
|
22 |
|
import java.util.Date; |
23 |
|
|
24 |
|
import javax.mail.Message; |
25 |
|
|
26 |
|
import org.junit.Test; |
27 |
|
|
28 |
|
import static org.junit.Assert.assertEquals; |
29 |
|
import static org.junit.Assert.assertTrue; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 4 |
Complexity Density: 0.13 |
|
37 |
|
public class MailStatusTest |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
39 |
1 |
@Test... |
40 |
|
public void setError() |
41 |
|
{ |
42 |
1 |
MailStatus status = new MailStatus(); |
43 |
1 |
status.setError(new Exception("outer", new Exception("inner"))); |
44 |
|
|
45 |
1 |
assertEquals("Exception: inner", status.getErrorSummary()); |
46 |
1 |
assertTrue(status.getErrorDescription().contains("outer")); |
47 |
1 |
assertTrue(status.getErrorDescription().contains("inner")); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void verifyToStringWhenStatusHasNoError() throws Exception |
52 |
|
{ |
53 |
1 |
ExtendedMimeMessage message = new ExtendedMimeMessage(); |
54 |
1 |
message.setHeader("Message-ID", "<local@domain>"); |
55 |
1 |
message.setType("type"); |
56 |
1 |
message.setRecipients(Message.RecipientType.TO, "john@doe.com"); |
57 |
|
|
58 |
1 |
MailStatus status = new MailStatus("batchid", message, MailState.PREPARE_SUCCESS); |
59 |
1 |
Date date = new Date(); |
60 |
1 |
status.setDate(date); |
61 |
|
|
62 |
1 |
assertEquals("messageId = [6ys1BeC6gnKA7srO/vs06XBZKZM=], batchId = [batchid], state = [prepare_success], date = [" |
63 |
|
+ date.toString() + "], recipients = [john@doe.com], type = [type]", status.toString()); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void verifyToStringWhenStatusHasError() throws Exception |
68 |
|
{ |
69 |
1 |
ExtendedMimeMessage message = new ExtendedMimeMessage(); |
70 |
1 |
message.setHeader("Message-ID", "<local@domain>"); |
71 |
1 |
message.setType("type"); |
72 |
1 |
message.setRecipients(Message.RecipientType.TO, "john@doe.com"); |
73 |
|
|
74 |
1 |
MailStatus status = new MailStatus("batchid", message, MailState.PREPARE_SUCCESS); |
75 |
1 |
Date date = new Date(); |
76 |
1 |
status.setDate(date); |
77 |
1 |
status.setError(new Exception("outer", new Exception("inner"))); |
78 |
|
|
79 |
1 |
assertTrue(status.toString().startsWith("messageId = [6ys1BeC6gnKA7srO/vs06XBZKZM=], batchId = [batchid], " |
80 |
|
+ "state = [prepare_success], date = [" + date.toString() + "], recipients = [john@doe.com], " |
81 |
|
+ "type = [type], errorSummary = [Exception: inner], errorDescription = [")); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
84 |
1 |
@Test... |
85 |
|
public void verifyToStringWhenWiki() throws Exception |
86 |
|
{ |
87 |
1 |
ExtendedMimeMessage message = new ExtendedMimeMessage(); |
88 |
1 |
message.setHeader("Message-ID", "<local@domain>"); |
89 |
1 |
message.setType("type"); |
90 |
1 |
message.setRecipients(Message.RecipientType.TO, "john@doe.com"); |
91 |
|
|
92 |
1 |
MailStatus status = new MailStatus("batchid", message, MailState.PREPARE_SUCCESS); |
93 |
1 |
Date date = new Date(); |
94 |
1 |
status.setDate(date); |
95 |
1 |
status.setWiki("wiki"); |
96 |
|
|
97 |
1 |
assertEquals("messageId = [6ys1BeC6gnKA7srO/vs06XBZKZM=], batchId = [batchid], state = [prepare_success], date = [" |
98 |
|
+ date.toString() + "], recipients = [john@doe.com], type = [type], wiki = [wiki]", status.toString()); |
99 |
|
} |
100 |
|
} |