@Test
  public void serializeErrors() throws Exception {
    MailStatusResult statusResult = mock(MailStatusResult.class);
    Date date = new Date();

    // Return failures for the test
    MailStatus status1 = new MailStatus();
    status1.setBatchId("batch1");
    status1.setState("prepare_error");
    status1.setDate(date);
    status1.setMessageId("<local@domain>");
    status1.setRecipients("*****@*****.**");
    status1.setErrorSummary("errorsummary1");
    status1.setErrorDescription("errordescription1");
    MailStatus status2 = new MailStatus();
    status2.setBatchId("batch2");
    status2.setState("send_error");
    status2.setDate(date);
    status2.setMessageId("<local@domain>");
    status2.setRecipients("*****@*****.**");
    status2.setErrorSummary("errorsummary2");
    status2.setErrorDescription("errordescription2");
    when(statusResult.getAllErrors()).thenReturn(Arrays.asList(status1, status2).iterator());

    assertEquals(
        "Some messages have failed to be sent: "
            + "[[messageId = [<local@domain>], batchId = [batch1], state = [prepare_error], "
            + "date = ["
            + date.toString()
            + "], recipients = [[email protected]], errorSummary = [errorsummary1], "
            + "errorDescription = [errordescription1]][messageId = [<local@domain>], batchId = [batch2], "
            + "state = [send_error], date = ["
            + date.toString()
            + "], recipients = [[email protected]], "
            + "errorSummary = [errorsummary2], errorDescription = [errordescription2]]]",
        MailStatusResultSerializer.serializeErrors(statusResult));
  }