Class MessageAwaiter
java.lang.Object
ch.martinelli.oss.testcontainers.mailpit.assertions.MessageAwaiter
Fluent builder for awaiting and asserting on messages.
Example usage:
assertThat(mailpitContainer)
.awaitMessage()
.withSubject("Welcome")
.from("noreply@example.com")
.to("user@example.com")
.isPresent();
-
Constructor Summary
ConstructorsConstructorDescriptionMessageAwaiter(MailpitClient client, Duration timeout, Duration pollInterval) -
Method Summary
Modifier and TypeMethodDescriptionFilters messages by CC recipient address.Filters messages by sender address.voidisAbsent()Asserts that no matching message exists (does not wait).Waits for a matching message and returns assertions for it.Filters messages by a custom predicate.Filters messages by recipient address.Filters messages that have attachments.Filters messages that have no attachments.withSubject(String subject) Filters messages by exact subject match.withSubjectContaining(String substring) Filters messages by subject containing a substring.
-
Constructor Details
-
MessageAwaiter
-
-
Method Details
-
withSubject
Filters messages by exact subject match.- Parameters:
subject- the expected subject- Returns:
- this awaiter
-
withSubjectContaining
Filters messages by subject containing a substring.- Parameters:
substring- the substring to search for- Returns:
- this awaiter
-
from
Filters messages by sender address.- Parameters:
senderAddress- the expected sender email address- Returns:
- this awaiter
-
to
Filters messages by recipient address.- Parameters:
recipientAddress- the expected recipient email address- Returns:
- this awaiter
-
cc
Filters messages by CC recipient address.- Parameters:
ccAddress- the expected CC email address- Returns:
- this awaiter
-
withAttachments
Filters messages that have attachments.- Returns:
- this awaiter
-
withoutAttachments
Filters messages that have no attachments.- Returns:
- this awaiter
-
matching
Filters messages by a custom predicate.- Parameters:
customPredicate- the predicate to apply- Returns:
- this awaiter
-
isPresent
Waits for a matching message and returns assertions for it.- Returns:
- MessageAssert for the found message
- Throws:
org.awaitility.core.ConditionTimeoutException- if no matching message is found within the timeout
-
isAbsent
public void isAbsent()Asserts that no matching message exists (does not wait).- Throws:
AssertionError- if a matching message is found
-