Class AssertableMailpitResponse
java.lang.Object
net.bugreaper.modules.api.assertable.AssertableResponseAbstract
net.bugreaper.modules.email.assertable.AssertableMailpitResponse
- All Implemented Interfaces:
ResponseMailpitInterface
public class AssertableMailpitResponse
extends net.bugreaper.modules.api.assertable.AssertableResponseAbstract
implements ResponseMailpitInterface
Provides a fluent API for asserting and extracting data from Email messages (API responses).
This class is designed to be used in a chainable manner, allowing multiple assertions to be performed in a single readable statement.
Usage Example:
mailpit.getLatestEmailInMailbox("my_email@gmail.com")
.seeEmailContainsFrom("sender@gmail.com")
.seeEmailAttachmentsCountExactly(2);
Design Notes:
- All assertion methods return
thisto support fluent chaining. - Assertion logic is delegated to internal helper methods to keep steps readable.
- Failures should throw assertion errors to immediately fail the test.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheck()Asserts that the response body is valid for subsequent checks.Retrieves a field value of any type from the Mailpit response body.seeEmailAttachmentsCountExactly(int expectedCount) Asserts that the email message contains exactly the expected number of attachments.seeEmailBccCountExactly(int expectedCount) Asserts that the email message contains exactly the expected number of "Bcc" email addresses.seeEmailBodyContains(String expectedSubString) Asserts that the email message body contains the expected string.seeEmailBodyEqual(String expectedBody) Asserts that the email message body equals the expected string.seeEmailCcCountExactly(int expectedCount) Asserts that the email message contains exactly the expected number of "Cc" email addresses.seeEmailContainsBcc(String expectedEmail) Asserts that the email message contains the expected email address in the "Bcc" field.seeEmailContainsCc(String expectedEmail) Asserts that the email message contains the expected email address in the "Cc" field.seeEmailContainsFrom(String expectedEmail) Asserts that the email message contains the expected email address in the "From" field.seeEmailContainsReplyTo(String expectedEmail) Asserts that the email message contains the expected email address in the "ReplyTo" field.seeEmailContainsTo(String expectedEmail) Asserts that the email message contains the expected email address in the "To" field.seeEmailReplyToCountExactly(int expectedCount) Asserts that the email message contains exactly the expected number of "ReplyTo" email addresses.seeEmailSubjectContains(String expectedSubString) Asserts that the email message subject contains the expected string.seeEmailSubjectEqual(String expectedSubject) Asserts that the email message subject equals the expected string.seeEmailToCountExactly(int expectedCount) Asserts that the email message contains exactly the expected number of "To" email addresses.seeResponseBodyFieldMatch(String path, org.hamcrest.Matcher<?> matcher) Asserts that the email message body matches the specified matcher.Methods inherited from class net.bugreaper.modules.api.assertable.AssertableResponseAbstract
grabDataFromResponseByPathMethod, grabResponseBodyMethod, grabResponseHeaderMethod, grabStringFromResponseByPathMethod, seeResponseBodyElementsCountMethod, seeResponseBodyFieldMatchMethod, seeResponseCodeIsMethod, seeResponseCodeIsSuccessfulMethod, seeResponseContainsExtendedJsonMethod, seeResponseContainsJsonMethod, seeResponseContainsJsonMethod, seeResponseContainsJsonStrictOrderMethod, seeResponseContainsJsonSubsetMethod, seeResponseExactlyMatchJsonIgnoringOrderMethod, seeResponseExactlyMatchJsonMethod, seeResponseExactlyMatchJsonMethod, seeResponseHeaderMatchMethod, seeResponseIsJsonTypeMethod, seeResponseMatchesJsonSchemaMethod, seeResponseMatchesXmlSchemaMethod, seeResponseTimeLessMethod
-
Constructor Details
-
AssertableMailpitResponse
public AssertableMailpitResponse(io.restassured.response.Response response)
-
-
Method Details
-
check
Description copied from interface:ResponseMailpitInterfaceAsserts that the response body is valid for subsequent checks.Used internally by EmailMailpit methods.
- Specified by:
checkin interfaceResponseMailpitInterface- Returns:
- this instance for method chaining
-
seeResponseBodyFieldMatch
@Step("\u2191(Email-mp)[ASSERT] Response body field: \'{path}\' <{matcher}>") public AssertableMailpitResponse seeResponseBodyFieldMatch(String path, org.hamcrest.Matcher<?> matcher) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message body matches the specified matcher.NOTE: Use for some custom asserts or not yet supported features
- Specified by:
seeResponseBodyFieldMatchin interfaceResponseMailpitInterface- Parameters:
path- path to the field (for example:data.user.id)matcher- Matcher- Returns:
- this instance for method chaining
-
seeEmailBodyEqual
@Step("\u2191(Email-mp)[ASSERT] Email Body EQUAL to:") public AssertableMailpitResponse seeEmailBodyEqual(@Param(mode=HIDDEN) String expectedBody) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message body equals the expected string.- Specified by:
seeEmailBodyEqualin interfaceResponseMailpitInterface- Parameters:
expectedBody- expected email body- Returns:
- this instance for method chaining
-
seeEmailBodyContains
@Step("\u2191(Email-mp)[ASSERT] Email Body CONTAINS:") public AssertableMailpitResponse seeEmailBodyContains(@Param(mode=HIDDEN) String expectedSubString) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message body contains the expected string.- Specified by:
seeEmailBodyContainsin interfaceResponseMailpitInterface- Parameters:
expectedSubString- expected substring- Returns:
- this instance for method chaining
-
seeEmailSubjectEqual
@Step("\u2191(Email-mp)[ASSERT] Email Subject EQUAL to:") public AssertableMailpitResponse seeEmailSubjectEqual(@Param(mode=HIDDEN) String expectedSubject) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message subject equals the expected string.- Specified by:
seeEmailSubjectEqualin interfaceResponseMailpitInterface- Parameters:
expectedSubject- expected email subject- Returns:
- this instance for method chaining
-
seeEmailSubjectContains
@Step("\u2191(Email-mp)[ASSERT] Email Subject CONTAINS:") public AssertableMailpitResponse seeEmailSubjectContains(@Param(mode=HIDDEN) String expectedSubString) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message subject contains the expected string.- Specified by:
seeEmailSubjectContainsin interfaceResponseMailpitInterface- Parameters:
expectedSubString- expected substring- Returns:
- this instance for method chaining
-
seeEmailContainsFrom
@Step("\u2191(Email-mp)[ASSERT] Email has \'From\': <{expectedEmail}>") public AssertableMailpitResponse seeEmailContainsFrom(String expectedEmail) Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains the expected email address in the "From" field.- Specified by:
seeEmailContainsFromin interfaceResponseMailpitInterface- Parameters:
expectedEmail- expected email address in the "From" field- Returns:
- this instance for method chaining
-
seeEmailContainsTo
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains the expected email address in the "To" field.- Specified by:
seeEmailContainsToin interfaceResponseMailpitInterface- Parameters:
expectedEmail- expected email address in the "To" field- Returns:
- this instance for method chaining
-
seeEmailContainsCc
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains the expected email address in the "Cc" field.- Specified by:
seeEmailContainsCcin interfaceResponseMailpitInterface- Parameters:
expectedEmail- expected email address in the "Cc" field- Returns:
- this instance for method chaining
-
seeEmailContainsBcc
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains the expected email address in the "Bcc" field.- Specified by:
seeEmailContainsBccin interfaceResponseMailpitInterface- Parameters:
expectedEmail- expected email address in the "Bcc" field- Returns:
- this instance for method chaining
-
seeEmailContainsReplyTo
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains the expected email address in the "ReplyTo" field.- Specified by:
seeEmailContainsReplyToin interfaceResponseMailpitInterface- Parameters:
expectedEmail- expected email address in the "ReplyTo" field- Returns:
- this instance for method chaining
-
seeEmailAttachmentsCountExactly
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains exactly the expected number of attachments.- Specified by:
seeEmailAttachmentsCountExactlyin interfaceResponseMailpitInterface- Parameters:
expectedCount- expected number of attachments- Returns:
- this instance for method chaining
-
seeEmailToCountExactly
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains exactly the expected number of "To" email addresses.- Specified by:
seeEmailToCountExactlyin interfaceResponseMailpitInterface- Parameters:
expectedCount- expected number of "To" email addresses in the message- Returns:
- this instance for method chaining
-
seeEmailCcCountExactly
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains exactly the expected number of "Cc" email addresses.- Specified by:
seeEmailCcCountExactlyin interfaceResponseMailpitInterface- Parameters:
expectedCount- expected number of "Cc" email addresses in the message- Returns:
- this instance for method chaining
-
seeEmailBccCountExactly
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains exactly the expected number of "Bcc" email addresses.- Specified by:
seeEmailBccCountExactlyin interfaceResponseMailpitInterface- Parameters:
expectedCount- expected number of "Bcc" email addresses in the message- Returns:
- this instance for method chaining
-
seeEmailReplyToCountExactly
Description copied from interface:ResponseMailpitInterfaceAsserts that the email message contains exactly the expected number of "ReplyTo" email addresses.- Specified by:
seeEmailReplyToCountExactlyin interfaceResponseMailpitInterface- Parameters:
expectedCount- expected number of "ReplyTo" email addresses in the message- Returns:
- this instance for method chaining
-
grabDataFromResponseByPath
Description copied from interface:ResponseMailpitInterfaceRetrieves a field value of any type from the Mailpit response body.- Specified by:
grabDataFromResponseByPathin interfaceResponseMailpitInterface- Parameters:
path- path to the field (for example:messages[0].To)- Returns:
- field value from the response body
-