ExpectedMultiPartEmail.java

  1. package fr.sii.ogham.testing.assertion.email;

  2. import static java.util.Arrays.asList;

  3. import java.util.List;

  4. /**
  5.  * Class used in tests for ensuring that the email is respected. It provides the
  6.  * following information:
  7.  * <ul>
  8.  * <li>The expected subject</li>
  9.  * <li>The expected bodies (an email may have several contents)</li>
  10.  * <li>The expected sender address</li>
  11.  * <li>The expected recipients (to, cc, bcc)</li>
  12.  * </ul>
  13.  *
  14.  * @author AurĂ©lien Baudet
  15.  * @see ExpectedEmailHeader
  16.  */
  17. public class ExpectedMultiPartEmail extends ExpectedEmailHeader {
  18.     /**
  19.      * List of expected contents
  20.      */
  21.     private List<ExpectedContent> expectedContents;


  22.     /**
  23.      * Initialize the expected email with provided values.
  24.      *
  25.      * @param subject
  26.      *            the expected subject of the email
  27.      * @param bodies
  28.      *            the list of expected bodies of the email with their respective
  29.      *            expected Mime Type
  30.      * @param from
  31.      *            the expected email sender address
  32.      * @param to
  33.      *            the expected recipients
  34.      */
  35.     public ExpectedMultiPartEmail(String subject, List<ExpectedContent> bodies, String from, String... to) {
  36.         super(subject, from, to);
  37.         this.expectedContents = bodies;
  38.     }
  39.    
  40.     /**
  41.      * Initialize the expected email with provided values.
  42.      *
  43.      * @param subject
  44.      *            the expected subject of the email
  45.      * @param bodies
  46.      *            the list of expected bodies of the email with their respective
  47.      *            expected Mime Type
  48.      * @param from
  49.      *            the expected email sender address
  50.      * @param to
  51.      *            the expected recipients
  52.      */
  53.     public ExpectedMultiPartEmail(String subject, ExpectedContent[] bodies, String from, String... to) {
  54.         this(subject, asList(bodies), from, to);
  55.     }

  56.     public List<ExpectedContent> getExpectedContents() {
  57.         return expectedContents;
  58.     }
  59. }