Interface MailPitInterface
- All Known Implementing Classes:
EmailMailpit
public interface MailPitInterface
-
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes all messages from all mailboxes.voidcleanMailbox(String mailbox) Deletes all messages from the mailbox.intReturns the number of messages in all mailboxes.Returns and logs (at INFO level) a human-readable summary of all resolved configuration values.intgetEmailsCountInMailbox(String mailbox) Returns the number of messages in the mailbox.getLatestEmailInMailbox(String mailbox) Returns the latest message from the mailbox in Mailpit format.voidseeAllEmailsCountExactly(int expectedCount) Asserts that the number of messages in all mailboxes equals the expected count.voidseeEmailsInMailboxCountExactly(String mailbox, int expectedCount) Asserts that the number of messages in specific mailbox equals the expected count.voidseeMailboxIsEmpty(String mailbox) Asserts that the mailbox is empty.voidseeMailboxIsNotEmpty(String mailbox) Asserts that the mailbox is not empty.setAwaitMs(int awaitMs) Configures the global await timeout for assertions that use await.voidsetChaosAuthentication(int code) Configures an authentication error in the Mailpit server for subsequent email sends.voidsetChaosRecipient(int code) Configures a recipient error in the Mailpit server for subsequent email sends.voidsetChaosSender(int code) Configures a sender error in the Mailpit server for subsequent email sends.voidDisables predefined chaos errors in the Mailpit server.
-
Method Details
-
cleanAllMailboxes
void cleanAllMailboxes()Deletes all messages from all mailboxes. -
cleanMailbox
Deletes all messages from the mailbox.- Parameters:
mailbox- mailbox address
-
getLatestEmailInMailbox
Returns the latest message from the mailbox in Mailpit format.- Parameters:
mailbox- mailbox address- Returns:
AssertableMailpitResponseUsage 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
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=trueandMP_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
Asserts that the number of messages in specific mailbox equals the expected count.Uses await.
- Parameters:
mailbox- mailbox addressexpectedCount- expected number of messages- Throws:
AssertionError- if the assertion fails
-
seeMailboxIsEmpty
Asserts that the mailbox is empty.Uses await.
- Parameters:
mailbox- mailbox address- Throws:
AssertionError- if the assertion fails
-
seeMailboxIsNotEmpty
Asserts that the mailbox is not empty.Uses await.
- Parameters:
mailbox- mailbox address- Throws:
AssertionError- if the assertion fails
-
setAwaitMs
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
-