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.Arrays; |
23 |
|
import java.util.Date; |
24 |
|
|
25 |
|
import org.junit.Test; |
26 |
|
|
27 |
|
import static org.junit.Assert.assertEquals; |
28 |
|
import static org.mockito.Mockito.mock; |
29 |
|
import static org.mockito.Mockito.when; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
|
37 |
|
public class MailStatusResultSerializerTest |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
39 |
1 |
@Test... |
40 |
|
public void serializeErrors() throws Exception |
41 |
|
{ |
42 |
1 |
MailStatusResult statusResult = mock(MailStatusResult.class); |
43 |
1 |
Date date = new Date(); |
44 |
|
|
45 |
|
|
46 |
1 |
MailStatus status1 = new MailStatus(); |
47 |
1 |
status1.setBatchId("batch1"); |
48 |
1 |
status1.setState("prepare_error"); |
49 |
1 |
status1.setDate(date); |
50 |
1 |
status1.setMessageId("6ys1BeC6gnKA7srO/vs06XBZKZM="); |
51 |
1 |
status1.setRecipients("john@doe.com"); |
52 |
1 |
status1.setErrorSummary("errorsummary1"); |
53 |
1 |
status1.setErrorDescription("errordescription1"); |
54 |
1 |
MailStatus status2 = new MailStatus(); |
55 |
1 |
status2.setBatchId("batch2"); |
56 |
1 |
status2.setState("send_error"); |
57 |
1 |
status2.setDate(date); |
58 |
1 |
status2.setMessageId("6ys1BeC6gnKA7srO/vs06XBZKZM="); |
59 |
1 |
status2.setRecipients("jane@doe.com"); |
60 |
1 |
status2.setErrorSummary("errorsummary2"); |
61 |
1 |
status2.setErrorDescription("errordescription2"); |
62 |
1 |
when(statusResult.getAllErrors()).thenReturn(Arrays.asList(status1, status2).iterator()); |
63 |
|
|
64 |
1 |
assertEquals("Some messages have failed to be sent: " |
65 |
|
+ "[[messageId = [6ys1BeC6gnKA7srO/vs06XBZKZM=], batchId = [batch1], state = [prepare_error], " |
66 |
|
+ "date = [" + date.toString() + "], recipients = [john@doe.com], errorSummary = [errorsummary1], " |
67 |
|
+ "errorDescription = [errordescription1]][messageId = [6ys1BeC6gnKA7srO/vs06XBZKZM=], " |
68 |
|
+ "batchId = [batch2], state = [send_error], date = [" + date.toString() + "], recipients = [jane@doe.com], " |
69 |
|
+ "errorSummary = [errorsummary2], errorDescription = [errordescription2]]]", |
70 |
|
MailStatusResultSerializer.serializeErrors(statusResult)); |
71 |
|
} |
72 |
|
} |