@Test public void testToString() { Mail mail = new Mail(); mail.setFrom("john@acme.org"); mail.setTo("peter@acme.org"); mail.setSubject("Test subject"); mail.setTextPart("Text content"); mail.setHeader("header1", "value1"); mail.setHeader("header2", "value2"); assertEquals("From [john@acme.org], To [peter@acme.org], Subject [Test subject], Text [Text content], " + "Headers [[header1] = [value1][header2] = [value2]]", mail.toString()); }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getFrom() != null) { buffer.append("From [" + getFrom() + "]"); } if (getTo() != null) { buffer.append(", To [" + getTo() + "]"); } if (getCc() != null) { buffer.append(", Cc [" + getCc() + "]"); } if (getBcc() != null) { buffer.append(", Bcc [" + getBcc() + "]"); } if (getSubject() != null) { buffer.append(", Subject [" + getSubject() + "]"); } if (getTextPart() != null) { buffer.append(", Text [" + getTextPart() + "]"); } if (getHtmlPart() != null) { buffer.append(", HTML [" + getHtmlPart() + "]"); } if (!getHeaders().isEmpty()) { buffer.append(", Headers [" + toStringHeaders() + "]"); } return buffer.toString(); }
Mail { @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getFrom() != null) { buffer.append("From [" + getFrom() + "]"); } if (getTo() != null) { buffer.append(", To [" + getTo() + "]"); } if (getCc() != null) { buffer.append(", Cc [" + getCc() + "]"); } if (getBcc() != null) { buffer.append(", Bcc [" + getBcc() + "]"); } if (getSubject() != null) { buffer.append(", Subject [" + getSubject() + "]"); } if (getTextPart() != null) { buffer.append(", Text [" + getTextPart() + "]"); } if (getHtmlPart() != null) { buffer.append(", HTML [" + getHtmlPart() + "]"); } if (!getHeaders().isEmpty()) { buffer.append(", Headers [" + toStringHeaders() + "]"); } return buffer.toString(); } }
Mail { @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getFrom() != null) { buffer.append("From [" + getFrom() + "]"); } if (getTo() != null) { buffer.append(", To [" + getTo() + "]"); } if (getCc() != null) { buffer.append(", Cc [" + getCc() + "]"); } if (getBcc() != null) { buffer.append(", Bcc [" + getBcc() + "]"); } if (getSubject() != null) { buffer.append(", Subject [" + getSubject() + "]"); } if (getTextPart() != null) { buffer.append(", Text [" + getTextPart() + "]"); } if (getHtmlPart() != null) { buffer.append(", HTML [" + getHtmlPart() + "]"); } if (!getHeaders().isEmpty()) { buffer.append(", Headers [" + toStringHeaders() + "]"); } return buffer.toString(); } Mail();  Mail(String from, String to, String cc, String bcc, String subject, String textPart, String htmlPart); }
Mail { @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getFrom() != null) { buffer.append("From [" + getFrom() + "]"); } if (getTo() != null) { buffer.append(", To [" + getTo() + "]"); } if (getCc() != null) { buffer.append(", Cc [" + getCc() + "]"); } if (getBcc() != null) { buffer.append(", Bcc [" + getBcc() + "]"); } if (getSubject() != null) { buffer.append(", Subject [" + getSubject() + "]"); } if (getTextPart() != null) { buffer.append(", Text [" + getTextPart() + "]"); } if (getHtmlPart() != null) { buffer.append(", HTML [" + getHtmlPart() + "]"); } if (!getHeaders().isEmpty()) { buffer.append(", Headers [" + toStringHeaders() + "]"); } return buffer.toString(); } Mail();  Mail(String from, String to, String cc, String bcc, String subject, String textPart, String htmlPart); List<Attachment> getAttachments(); void setAttachments(List<Attachment> attachments); String getFrom(); void setFrom(String from); String getTo(); void setTo(String to); String getCc(); void setCc(String cc); String getBcc(); void setBcc(String bcc); String getSubject(); void setSubject(String subject); String getTextPart(); void setTextPart(String message); @Override String toString(); String getHtmlPart(); void setHtmlPart(String htmlPart); void setHeader(String header, String value); String getHeader(String header); void setHeaders(Map<String, String> headers); Map<String, String> getHeaders(); }
Mail { @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getFrom() != null) { buffer.append("From [" + getFrom() + "]"); } if (getTo() != null) { buffer.append(", To [" + getTo() + "]"); } if (getCc() != null) { buffer.append(", Cc [" + getCc() + "]"); } if (getBcc() != null) { buffer.append(", Bcc [" + getBcc() + "]"); } if (getSubject() != null) { buffer.append(", Subject [" + getSubject() + "]"); } if (getTextPart() != null) { buffer.append(", Text [" + getTextPart() + "]"); } if (getHtmlPart() != null) { buffer.append(", HTML [" + getHtmlPart() + "]"); } if (!getHeaders().isEmpty()) { buffer.append(", Headers [" + toStringHeaders() + "]"); } return buffer.toString(); } Mail();  Mail(String from, String to, String cc, String bcc, String subject, String textPart, String htmlPart); List<Attachment> getAttachments(); void setAttachments(List<Attachment> attachments); String getFrom(); void setFrom(String from); String getTo(); void setTo(String to); String getCc(); void setCc(String cc); String getBcc(); void setBcc(String bcc); String getSubject(); void setSubject(String subject); String getTextPart(); void setTextPart(String message); @Override String toString(); String getHtmlPart(); void setHtmlPart(String htmlPart); void setHeader(String header, String value); String getHeader(String header); void setHeaders(Map<String, String> headers); Map<String, String> getHeaders();  }