1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.mail

File MailStatusResultSerializerTest.java

 

Code metrics

0
20
1
1
72
40
1
0.05
20
1
1

Classes

Class Line # Actions
MailStatusResultSerializerTest 37 20 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Unit tests for {@link MailStatusResultSerializer}.
33    *
34    * @version $Id: 88d9b809a19a09d75f979db5fce2a6a8e350000b $
35    * @since 6.4RC1
36    */
 
37    public class MailStatusResultSerializerTest
38    {
 
39  1 toggle @Test
40    public void serializeErrors() throws Exception
41    {
42  1 MailStatusResult statusResult = mock(MailStatusResult.class);
43  1 Date date = new Date();
44   
45    // Return failures for the test
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    }