Class ResponseBodyAssertion
java.lang.Object
org.apache.juneau.rest.client.assertion.ResponseBodyAssertion
A fluent assertion class for HTTP response bodies.
Obtain instances via ResponseAssertion.body().
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionand()Returns the parentResponseAssertionto continue assertion chaining.Asserts that the response body (as a UTF-8 string) contains the given substring.Asserts that the response body (as a UTF-8 string) equals the expected value.isEmpty()Asserts that the response body is empty (null or zero-length).Asserts that the response body is present and non-empty.startsWith(String prefix) Asserts that the response body starts with the given prefix.
-
Method Details
-
equals
Asserts that the response body (as a UTF-8 string) equals the expected value.- Parameters:
expected- The expected body string. May benull to assert an empty/absent body.- Returns:
- This object (for chaining).
- Throws:
AssertionError- If the body does not match.UncheckedIOException- If reading the body throwsIOException.
-
contains
Asserts that the response body (as a UTF-8 string) contains the given substring.- Parameters:
substring- The substring to look for. Must not benull .- Returns:
- This object (for chaining).
- Throws:
AssertionError- If the body is absent or does not contain the substring.UncheckedIOException- If reading the body throwsIOException.
-
isEmpty
Asserts that the response body is empty (null or zero-length).- Returns:
- This object (for chaining).
- Throws:
AssertionError- If the body is non-empty.UncheckedIOException- If reading the body throwsIOException.
-
isNotEmpty
Asserts that the response body is present and non-empty.- Returns:
- This object (for chaining).
- Throws:
AssertionError- If the body isnull or empty.UncheckedIOException- If reading the body throwsIOException.
-
startsWith
Asserts that the response body starts with the given prefix.- Parameters:
prefix- The expected prefix. Must not benull .- Returns:
- This object (for chaining).
- Throws:
AssertionError- If the body is absent or does not start with the prefix.UncheckedIOException- If reading the body throwsIOException.
-
and
Returns the parentResponseAssertionto continue assertion chaining.- Returns:
- The parent assertion. Never
null .
-