Interface ResponseAsserts
- All Known Implementing Classes:
AssertableResponse
public interface ResponseAsserts
-
Method Summary
Modifier and TypeMethodDescriptionseeResponseBodyElementsCount(int expectedCount) Asserts that the response body JSON array contains exactly the expected number of elements.seeResponseBodyFieldMatch(String path, org.hamcrest.Matcher<?> matcher) Asserts response Body field using custom matchers.seeResponseCodeIs(int statusCode) Asserts that the response StatusCode matches the expected status code.Asserts that the response StatusCode is in the 2xx range.seeResponseContainsExtendedJson(String expectedSetup) Asserts response JSON matches the expected JSON using contains, AND/OR, and optional checks.seeResponseContainsJson(String expectedBody) Asserts that the response JSON matches the expected JSON without strict array ordering.seeResponseContainsJson(Path filePath) Asserts that the response JSON matches the expected JSON without strict array ordering.seeResponseContainsJsonStrictOrder(String expectedBody) Asserts that the response JSON matches the expected JSON with strict array ordering.seeResponseContainsJsonSubset(String expectedBody) Asserts that the response JSON matches the expected JSON without strict array ordering.seeResponseExactlyMatchJson(String expectedBody) Asserts that the response JSON matches the expected JSON with strict array ordering.seeResponseExactlyMatchJson(Path filePath) Asserts that the response JSON matches the expected JSON with strict array ordering.seeResponseExactlyMatchJsonIgnoringOrder(String expectedBody) Asserts that the response JSON matches the expected JSON without strict array ordering.seeResponseHeaderMatch(String header, org.hamcrest.Matcher<?> matcher) Asserts response Header using custom matchers.Asserts that the response is JSON object or JSON array.seeResponseMatchesJsonSchema(Path filePath) Asserts that the response matches the JSON schema.seeResponseMatchesXmlSchema(Path filePath) Asserts that the response matches the XML schema.seeResponseTimeLess(long timeMs) Asserts that the response time is less than maximum expected.
-
Method Details
-
seeResponseCodeIs
Asserts that the response StatusCode matches the expected status code.- Parameters:
statusCode- expected HTTP StatusCode- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseCodeIsSuccessful
AssertableResponse seeResponseCodeIsSuccessful()Asserts that the response StatusCode is in the 2xx range.- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseBodyFieldMatch
Asserts response Body field using custom matchers.- Parameters:
path- path to field (data.user.id)matcher- Matcher- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseHeaderMatch
Asserts response Header using custom matchers.- Parameters:
header- header namematcher- Matcher- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseIsJsonType
AssertableResponse seeResponseIsJsonType()Asserts that the response is JSON object or JSON array.- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseTimeLess
Asserts that the response time is less than maximum expected.- Parameters:
timeMs- maximum expected response time in MS- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-
seeResponseContainsJsonSubset
Asserts that the response JSON matches the expected JSON without strict array ordering.Extra fields and the order of elements in arrays are ignored.
- Parameters:
expectedBody- expected JSON subset (array order is ignored and array size may differ)- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseContainsJson
Asserts that the response JSON matches the expected JSON without strict array ordering.Extra object fields are ignored, but additional array elements cause an
AssertionError.- Parameters:
expectedBody- expected JSON subset (array order is ignored, but the number of elements must match if provided)- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseContainsJson
Asserts that the response JSON matches the expected JSON without strict array ordering.Extra object fields are ignored, but additional array elements cause an
AssertionError.- Parameters:
filePath- path to the local file, including the file name, relative to resources, containing the expected JSON subset (array order is ignored, but the number of elements must match if provided)- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsnet.bugreaper.core.exceptions.FileReaderException- if reading the file fails or the provided data is not valid JSON
-
seeResponseContainsExtendedJson
Asserts response JSON matches the expected JSON using contains, AND/OR, and optional checks.Same behavior as
JsonAsserts.assertJsonsExtended(String, String).- Parameters:
expectedSetup- expected JSON with contains, AND/OR, and optional checks- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseExactlyMatchJson
Asserts that the response JSON matches the expected JSON with strict array ordering.Extra object fields cause an
AssertionError.- Parameters:
expectedBody- expected full JSON with strict array ordering- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseExactlyMatchJson
Asserts that the response JSON matches the expected JSON with strict array ordering.Extra object fields cause an
AssertionError.- Parameters:
filePath- path to the local file, including the file name, relative to resources, containing the expected JSON with strict array ordering- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsnet.bugreaper.core.exceptions.FileReaderException- if reading the file fails or the provided data is not valid JSON
-
seeResponseContainsJsonStrictOrder
Asserts that the response JSON matches the expected JSON with strict array ordering.Extra object fields are ignored.
- Parameters:
expectedBody- expected part of JSON with strict ordered arrays- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseExactlyMatchJsonIgnoringOrder
Asserts that the response JSON matches the expected JSON without strict array ordering.Extra object fields cause an
AssertionError.- Parameters:
expectedBody- expected full JSON with arrays (array order is ignored)- Throws:
AssertionError- if the assertion failsIllegalArgumentException- if the provided data is not valid JSON
-
seeResponseMatchesJsonSchema
Asserts that the response matches the JSON schema.- Parameters:
filePath- path to the local file, including the file name, relative to resources, containing the JSON schema- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsnet.bugreaper.core.exceptions.FileReaderException- if reading the file fails or the provided data is not valid JSON
-
seeResponseMatchesXmlSchema
Asserts that the response matches the XML schema.- Parameters:
filePath- path to the local file, including the file name, relative to resources, containing the XML schema- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion failsnet.bugreaper.core.exceptions.FileReaderException- if reading the file fails
-
seeResponseBodyElementsCount
Asserts that the response body JSON array contains exactly the expected number of elements.- Parameters:
expectedCount- expected number of elements- Returns:
- this instance for method chaining
- Throws:
AssertionError- if the assertion fails
-