@Test void buildShouldWorkWhenMandatoryFieldsArePresent() { Instant currentDate = Instant.now(); SubMessage expected = new SubMessage(ImmutableMap.of("key", "value"), Optional.empty(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), "subject", currentDate, Optional.empty(), Optional.empty(), ImmutableList.of(), ImmutableMap.of()); SubMessage tested = SubMessage.builder() .headers(ImmutableMap.of("key", "value")) .subject("subject") .date(currentDate) .build(); assertThat(tested).isEqualToComparingFieldByField(expected); }
public static Builder builder() { return new Builder(); }
SubMessage { public static Builder builder() { return new Builder(); } }
SubMessage { public static Builder builder() { return new Builder(); } @VisibleForTesting  SubMessage(ImmutableMap<String, String> headers,
                                  Optional<Emailer> from,
                                  ImmutableList<Emailer> to,
                                  ImmutableList<Emailer> cc,
                                  ImmutableList<Emailer> bcc,
                                  ImmutableList<Emailer> replyTo,
                                  String subject,
                                  Instant date,
                                  Optional<String> textBody,
                                  Optional<String> htmlBody,
                                  ImmutableList<Attachment> attachments,
                                  ImmutableMap<BlobId, SubMessage> attachedMessages); }
SubMessage { public static Builder builder() { return new Builder(); } @VisibleForTesting  SubMessage(ImmutableMap<String, String> headers,
                                  Optional<Emailer> from,
                                  ImmutableList<Emailer> to,
                                  ImmutableList<Emailer> cc,
                                  ImmutableList<Emailer> bcc,
                                  ImmutableList<Emailer> replyTo,
                                  String subject,
                                  Instant date,
                                  Optional<String> textBody,
                                  Optional<String> htmlBody,
                                  ImmutableList<Attachment> attachments,
                                  ImmutableMap<BlobId, SubMessage> attachedMessages); static Builder builder(); ImmutableMap<String, String> getHeaders(); Optional<Emailer> getFrom(); ImmutableList<Emailer> getTo(); ImmutableList<Emailer> getCc(); ImmutableList<Emailer> getBcc(); ImmutableList<Emailer> getReplyTo(); String getSubject(); Instant getDate(); Optional<String> getTextBody(); Optional<String> getHtmlBody(); ImmutableList<Attachment> getAttachments(); ImmutableMap<BlobId, SubMessage> getAttachedMessages(); }
SubMessage { public static Builder builder() { return new Builder(); } @VisibleForTesting  SubMessage(ImmutableMap<String, String> headers,
                                  Optional<Emailer> from,
                                  ImmutableList<Emailer> to,
                                  ImmutableList<Emailer> cc,
                                  ImmutableList<Emailer> bcc,
                                  ImmutableList<Emailer> replyTo,
                                  String subject,
                                  Instant date,
                                  Optional<String> textBody,
                                  Optional<String> htmlBody,
                                  ImmutableList<Attachment> attachments,
                                  ImmutableMap<BlobId, SubMessage> attachedMessages); static Builder builder(); ImmutableMap<String, String> getHeaders(); Optional<Emailer> getFrom(); ImmutableList<Emailer> getTo(); ImmutableList<Emailer> getCc(); ImmutableList<Emailer> getBcc(); ImmutableList<Emailer> getReplyTo(); String getSubject(); Instant getDate(); Optional<String> getTextBody(); Optional<String> getHtmlBody(); ImmutableList<Attachment> getAttachments(); ImmutableMap<BlobId, SubMessage> getAttachedMessages();  }