Class MessageAssert
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>
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 -
Method Summary
Modifier and TypeMethodDescriptionReturns 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).hasSnippetContaining(String text) Verifies the message snippet contains the given text.hasSubject(String expectedSubject) Verifies the message subject matches exactly.hasSubjectContaining(String substring) Verifies the message subject contains the given substring.Verifies the message has the given tag.Verifies the message has all the given tags.Verifies the sender email address.isFromName(String expectedName) Verifies the sender has the expected display name.isRead()Verifies the message has been read.isUnread()Verifies the message is unread.wasCreatedAfter(Instant instant) Verifies the message was created after the given instant.wasCreatedBefore(Instant 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, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Constructor Details
-
MessageAssert
-
-
Method Details
-
hasSubject
Verifies the message subject matches exactly.- Parameters:
expectedSubject- the expected subject- Returns:
- this assertion object
-
hasSubjectContaining
Verifies the message subject contains the given substring.- Parameters:
substring- the expected substring- Returns:
- this assertion object
-
isFrom
Verifies the sender email address.- Parameters:
expectedAddress- the expected sender email address- Returns:
- this assertion object
-
isFromName
Verifies the sender has the expected display name.- Parameters:
expectedName- the expected sender name- Returns:
- this assertion object
-
hasRecipient
Verifies the message has the given recipient.- Parameters:
expectedAddress- the expected recipient email address- Returns:
- this assertion object
-
hasRecipientCount
Verifies the message has exactly the expected number of recipients (To).- Parameters:
expectedCount- the expected recipient count- Returns:
- this assertion object
-
hasCcRecipient
Verifies the message has the given CC recipient.- Parameters:
expectedAddress- the expected CC recipient email address- Returns:
- this assertion object
-
hasBccRecipient
Verifies the message has the given BCC recipient.- Parameters:
expectedAddress- the expected BCC recipient email address- Returns:
- this assertion object
-
hasAttachments
Verifies the message has at least one attachment.- Returns:
- this assertion object
-
hasNoAttachments
Verifies the message has no attachments.- Returns:
- this assertion object
-
hasAttachmentCount
Verifies the message has exactly the expected number of attachments.- Parameters:
expectedCount- the expected attachment count- Returns:
- this assertion object
-
isRead
Verifies the message has been read.- Returns:
- this assertion object
-
isUnread
Verifies the message is unread.- Returns:
- this assertion object
-
wasCreatedAfter
Verifies the message was created after the given instant.- Parameters:
instant- the instant to compare against- Returns:
- this assertion object
-
wasCreatedBefore
Verifies the message was created before the given instant.- Parameters:
instant- the instant to compare against- Returns:
- this assertion object
-
hasSnippetContaining
Verifies the message snippet contains the given text.- Parameters:
text- the expected text- Returns:
- this assertion object
-
hasTag
Verifies the message has the given tag.- Parameters:
tag- the expected tag- Returns:
- this assertion object
-
hasTags
Verifies the message has all the given tags.- Parameters:
expectedTags- the expected tags- Returns:
- this assertion object
-
getMessage
Returns the underlying message for further inspection.- Returns:
- the message being asserted
-
fromAddress
Returns assertions for the sender address.- Returns:
- AddressAssert for the sender
- Throws:
AssertionError- if no sender is set
-