Class MailpitContainerAssert

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

public class MailpitContainerAssert extends org.assertj.core.api.AbstractAssert<MailpitContainerAssert,MailpitContainer>
AssertJ assertions for MailpitContainer.

Example usage:


 assertThat(mailpitContainer)
     .isRunning()
     .hasMessages()
     .hasMessageCount(1);

 assertThat(mailpitContainer)
     .withTimeout(Duration.ofSeconds(30))
     .awaitMessage()
     .withSubject("Welcome")
     .isPresent();
 
  • 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
    Creates a message awaiter to wait for and assert on messages.
    awaitMessageCount(int expectedCount)
    Waits until the mailbox contains exactly the expected number of messages.
    Waits until the mailbox contains at least one message.
    Returns assertions on the first message in the mailbox.
    hasMessageCount(int expectedCount)
    Verifies that the mailbox contains exactly the expected number of messages.
    hasMessageFrom(String senderAddress)
    Verifies that there is a message from the given sender.
    Verifies that the mailbox contains at least one message.
    hasMessageTo(String recipientAddress)
    Verifies that there is a message sent to the given recipient.
    Verifies that there is a message with the given subject.
    Verifies that the mailbox is empty.
    Verifies that the container is running.
    Returns assertions on the last message in the mailbox.
    Returns assertions on all messages in the mailbox.
    withPollInterval(Duration pollInterval)
    Configures the poll interval for await operations.
    Configures the timeout for await operations.

    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

    • MailpitContainerAssert

      public MailpitContainerAssert(MailpitContainer actual)
  • Method Details

    • isRunning

      public MailpitContainerAssert isRunning()
      Verifies that the container is running.
      Returns:
      this assertion object
    • hasMessages

      public MailpitContainerAssert hasMessages()
      Verifies that the mailbox contains at least one message.
      Returns:
      this assertion object
    • hasNoMessages

      public MailpitContainerAssert hasNoMessages()
      Verifies that the mailbox is empty.
      Returns:
      this assertion object
    • hasMessageCount

      public MailpitContainerAssert hasMessageCount(int expectedCount)
      Verifies that the mailbox contains exactly the expected number of messages.
      Parameters:
      expectedCount - the expected message count
      Returns:
      this assertion object
    • withTimeout

      public MailpitContainerAssert withTimeout(Duration timeout)
      Configures the timeout for await operations.
      Parameters:
      timeout - the maximum time to wait
      Returns:
      this assertion object
    • withPollInterval

      public MailpitContainerAssert withPollInterval(Duration pollInterval)
      Configures the poll interval for await operations.
      Parameters:
      pollInterval - the interval between polls
      Returns:
      this assertion object
    • awaitMessage

      public MessageAwaiter awaitMessage()
      Creates a message awaiter to wait for and assert on messages.
      Returns:
      a new MessageAwaiter for fluent assertions
    • awaitMessages

      public MailpitContainerAssert awaitMessages()
      Waits until the mailbox contains at least one message.
      Returns:
      this assertion object
    • awaitMessageCount

      public MailpitContainerAssert awaitMessageCount(int expectedCount)
      Waits until the mailbox contains exactly the expected number of messages.
      Parameters:
      expectedCount - the expected message count
      Returns:
      this assertion object
    • firstMessage

      public MessageAssert firstMessage()
      Returns assertions on the first message in the mailbox.
      Returns:
      MessageAssert for the first message
      Throws:
      AssertionError - if no messages exist
    • lastMessage

      public MessageAssert lastMessage()
      Returns assertions on the last message in the mailbox.
      Returns:
      MessageAssert for the last message
      Throws:
      AssertionError - if no messages exist
    • messages

      public MessagesAssert messages()
      Returns assertions on all messages in the mailbox.
      Returns:
      MessagesAssert for all messages
    • hasMessageWithSubject

      public MailpitContainerAssert hasMessageWithSubject(String subject)
      Verifies that there is a message with the given subject.
      Parameters:
      subject - the expected subject
      Returns:
      this assertion object
    • hasMessageTo

      public MailpitContainerAssert hasMessageTo(String recipientAddress)
      Verifies that there is a message sent to the given recipient.
      Parameters:
      recipientAddress - the expected recipient email address
      Returns:
      this assertion object
    • hasMessageFrom

      public MailpitContainerAssert hasMessageFrom(String senderAddress)
      Verifies that there is a message from the given sender.
      Parameters:
      senderAddress - the expected sender email address
      Returns:
      this assertion object