Interface MailPitInterface

All Known Implementing Classes:
EmailMailpit

public interface MailPitInterface
  • Method Details

    • cleanAllMailboxes

      void cleanAllMailboxes()
      Deletes all messages from all mailboxes.
    • cleanMailbox

      void cleanMailbox(String mailbox)
      Deletes all messages from the mailbox.
      Parameters:
      mailbox - mailbox address
    • getLatestEmailInMailbox

      AssertableMailpitResponse getLatestEmailInMailbox(String mailbox)
      Returns the latest message from the mailbox in Mailpit format.
      Parameters:
      mailbox - mailbox address
      Returns:
      AssertableMailpitResponse

      Usage Example:

      
       mailpit.getLatestEmailInMailbox("my_email@gmail.com")
               .seeEmailContainsFrom("sender@gmail.com")
               .seeEmailAttachmentsCountExactly(2);
       

      can be provided multiple asserts

    • getAllEmailsCount

      int getAllEmailsCount()
      Returns the number of messages in all mailboxes.
      Returns:
      number of messages in all mailboxes
    • getEmailsCountInMailbox

      int getEmailsCountInMailbox(String mailbox)
      Returns the number of messages in the mailbox.
      Parameters:
      mailbox - mailbox address
      Returns:
      number of messages in the mailbox
    • unsetChaos

      void unsetChaos()
      Disables predefined chaos errors in the Mailpit server.

      Works only when MP_ENABLE_CHAOS=true.

    • setChaosAuthentication

      void setChaosAuthentication(int code)
      Configures an authentication error in the Mailpit server for subsequent email sends.

      Works only when MP_ENABLE_CHAOS=true and MP_SMTP_AUTH=true.

      Parameters:
      code - error code between 400 and 599
      Throws:
      MailpitHelperException - if the error code is invalid
    • setChaosRecipient

      void setChaosRecipient(int code)
      Configures a recipient error in the Mailpit server for subsequent email sends.

      Works only when MP_ENABLE_CHAOS=true.

      Parameters:
      code - error code between 400 and 599
      Throws:
      MailpitHelperException - if the error code is invalid
    • setChaosSender

      void setChaosSender(int code)
      Configures a sender error in the Mailpit server for subsequent email sends.

      Works only when MP_ENABLE_CHAOS=true.

      Parameters:
      code - error code between 400 and 599
      Throws:
      MailpitHelperException - if the error code is invalid
    • seeAllEmailsCountExactly

      void seeAllEmailsCountExactly(int expectedCount)
      Asserts that the number of messages in all mailboxes equals the expected count.

      Uses await.

      Parameters:
      expectedCount - expected number of messages
      Throws:
      AssertionError - if the assertion fails
    • seeEmailsInMailboxCountExactly

      void seeEmailsInMailboxCountExactly(String mailbox, int expectedCount)
      Asserts that the number of messages in specific mailbox equals the expected count.

      Uses await.

      Parameters:
      mailbox - mailbox address
      expectedCount - expected number of messages
      Throws:
      AssertionError - if the assertion fails
    • seeMailboxIsEmpty

      void seeMailboxIsEmpty(String mailbox)
      Asserts that the mailbox is empty.

      Uses await.

      Parameters:
      mailbox - mailbox address
      Throws:
      AssertionError - if the assertion fails
    • seeMailboxIsNotEmpty

      void seeMailboxIsNotEmpty(String mailbox)
      Asserts that the mailbox is not empty.

      Uses await.

      Parameters:
      mailbox - mailbox address
      Throws:
      AssertionError - if the assertion fails
    • setAwaitMs

      EmailMailpit setAwaitMs(int awaitMs)
      Configures the global await timeout for assertions that use await.
      Parameters:
      awaitMs - await timeout in milliseconds
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if the provided timeout is invalid or less than 200 milliseconds
    • getConfigSummary

      String getConfigSummary()
      Returns and logs (at INFO level) a human-readable summary of all resolved configuration values.

      The summary includes values loaded from the YAML configuration file as well as any fields overridden programmatically after construction. Optional fields that were not present in the configuration and resolved via default values may also be included.

      Returns:
      String with summary