java.lang.Object
org.assertj.core.api.AbstractAssert<MessageAssert,Message>
ch.martinelli.oss.testcontainers.mailpit.assertions.MessageAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<MessageAssert,Message>, org.assertj.core.api.Descriptable<MessageAssert>, org.assertj.core.api.ExtensionPoints<MessageAssert,Message>

public class MessageAssert extends org.assertj.core.api.AbstractAssert<MessageAssert,Message>
AssertJ assertions for Message.

Example usage:


 assertThat(message)
     .hasSubject("Welcome")
     .isFrom("noreply@example.com")
     .hasRecipient("user@example.com")
     .hasNoAttachments();
 
  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns assertions for the sender address.
    Returns the underlying message for further inspection.
    hasAttachmentCount(int expectedCount)
    Verifies the message has exactly the expected number of attachments.
    Verifies the message has at least one attachment.
    hasBccRecipient(String expectedAddress)
    Verifies the message has the given BCC recipient.
    hasCcRecipient(String expectedAddress)
    Verifies the message has the given CC recipient.
    Verifies the message has no attachments.
    hasRecipient(String expectedAddress)
    Verifies the message has the given recipient.
    hasRecipientCount(int expectedCount)
    Verifies the message has exactly the expected number of recipients (To).
    Verifies the message snippet contains the given text.
    hasSubject(String expectedSubject)
    Verifies the message subject matches exactly.
    Verifies the message subject contains the given substring.
    Verifies the message has the given tag.
    hasTags(String... expectedTags)
    Verifies the message has all the given tags.
    isFrom(String expectedAddress)
    Verifies the sender email address.
    isFromName(String expectedName)
    Verifies the sender has the expected display name.
    Verifies the message has been read.
    Verifies the message is unread.
    Verifies the message was created after the given instant.
    Verifies the message was created before the given instant.

    Methods inherited from class org.assertj.core.api.AbstractAssert

    actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingEquals, usingEquals, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, as, as, describedAs, describedAs
  • Constructor Details

    • MessageAssert

      public MessageAssert(Message actual)
  • Method Details

    • hasSubject

      public MessageAssert hasSubject(String expectedSubject)
      Verifies the message subject matches exactly.
      Parameters:
      expectedSubject - the expected subject
      Returns:
      this assertion object
    • hasSubjectContaining

      public MessageAssert hasSubjectContaining(String substring)
      Verifies the message subject contains the given substring.
      Parameters:
      substring - the expected substring
      Returns:
      this assertion object
    • isFrom

      public MessageAssert isFrom(String expectedAddress)
      Verifies the sender email address.
      Parameters:
      expectedAddress - the expected sender email address
      Returns:
      this assertion object
    • isFromName

      public MessageAssert isFromName(String expectedName)
      Verifies the sender has the expected display name.
      Parameters:
      expectedName - the expected sender name
      Returns:
      this assertion object
    • hasRecipient

      public MessageAssert hasRecipient(String expectedAddress)
      Verifies the message has the given recipient.
      Parameters:
      expectedAddress - the expected recipient email address
      Returns:
      this assertion object
    • hasRecipientCount

      public MessageAssert hasRecipientCount(int expectedCount)
      Verifies the message has exactly the expected number of recipients (To).
      Parameters:
      expectedCount - the expected recipient count
      Returns:
      this assertion object
    • hasCcRecipient

      public MessageAssert hasCcRecipient(String expectedAddress)
      Verifies the message has the given CC recipient.
      Parameters:
      expectedAddress - the expected CC recipient email address
      Returns:
      this assertion object
    • hasBccRecipient

      public MessageAssert hasBccRecipient(String expectedAddress)
      Verifies the message has the given BCC recipient.
      Parameters:
      expectedAddress - the expected BCC recipient email address
      Returns:
      this assertion object
    • hasAttachments

      public MessageAssert hasAttachments()
      Verifies the message has at least one attachment.
      Returns:
      this assertion object
    • hasNoAttachments

      public MessageAssert hasNoAttachments()
      Verifies the message has no attachments.
      Returns:
      this assertion object
    • hasAttachmentCount

      public MessageAssert hasAttachmentCount(int expectedCount)
      Verifies the message has exactly the expected number of attachments.
      Parameters:
      expectedCount - the expected attachment count
      Returns:
      this assertion object
    • isRead

      public MessageAssert isRead()
      Verifies the message has been read.
      Returns:
      this assertion object
    • isUnread

      public MessageAssert isUnread()
      Verifies the message is unread.
      Returns:
      this assertion object
    • wasCreatedAfter

      public MessageAssert wasCreatedAfter(Instant instant)
      Verifies the message was created after the given instant.
      Parameters:
      instant - the instant to compare against
      Returns:
      this assertion object
    • wasCreatedBefore

      public MessageAssert wasCreatedBefore(Instant instant)
      Verifies the message was created before the given instant.
      Parameters:
      instant - the instant to compare against
      Returns:
      this assertion object
    • hasSnippetContaining

      public MessageAssert hasSnippetContaining(String text)
      Verifies the message snippet contains the given text.
      Parameters:
      text - the expected text
      Returns:
      this assertion object
    • hasTag

      public MessageAssert hasTag(String tag)
      Verifies the message has the given tag.
      Parameters:
      tag - the expected tag
      Returns:
      this assertion object
    • hasTags

      public MessageAssert hasTags(String... expectedTags)
      Verifies the message has all the given tags.
      Parameters:
      expectedTags - the expected tags
      Returns:
      this assertion object
    • getMessage

      public Message getMessage()
      Returns the underlying message for further inspection.
      Returns:
      the message being asserted
    • fromAddress

      public AddressAssert fromAddress()
      Returns assertions for the sender address.
      Returns:
      AddressAssert for the sender
      Throws:
      AssertionError - if no sender is set