Interface ResponseAsserts

All Known Implementing Classes:
AssertableResponse

public interface ResponseAsserts
  • Method Details

    • seeResponseCodeIs

      AssertableResponse seeResponseCodeIs(int statusCode)
      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

      AssertableResponse seeResponseBodyFieldMatch(String path, org.hamcrest.Matcher<?> matcher)
      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

      AssertableResponse seeResponseHeaderMatch(String header, org.hamcrest.Matcher<?> matcher)
      Asserts response Header using custom matchers.
      Parameters:
      header - header name
      matcher - 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

      AssertableResponse seeResponseTimeLess(long timeMs)
      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

      AssertableResponse seeResponseContainsJsonSubset(String expectedBody)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseContainsJson

      AssertableResponse seeResponseContainsJson(String expectedBody)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseContainsJson

      AssertableResponse seeResponseContainsJson(Path filePath)
      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 fails
      net.bugreaper.core.exceptions.FileReaderException - if reading the file fails or the provided data is not valid JSON
    • seeResponseContainsExtendedJson

      AssertableResponse seeResponseContainsExtendedJson(String expectedSetup)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseExactlyMatchJson

      AssertableResponse seeResponseExactlyMatchJson(String expectedBody)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseExactlyMatchJson

      AssertableResponse seeResponseExactlyMatchJson(Path filePath)
      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 fails
      net.bugreaper.core.exceptions.FileReaderException - if reading the file fails or the provided data is not valid JSON
    • seeResponseContainsJsonStrictOrder

      AssertableResponse seeResponseContainsJsonStrictOrder(String expectedBody)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseExactlyMatchJsonIgnoringOrder

      AssertableResponse seeResponseExactlyMatchJsonIgnoringOrder(String expectedBody)
      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 fails
      IllegalArgumentException - if the provided data is not valid JSON
    • seeResponseMatchesJsonSchema

      AssertableResponse seeResponseMatchesJsonSchema(Path filePath)
      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 fails
      net.bugreaper.core.exceptions.FileReaderException - if reading the file fails or the provided data is not valid JSON
    • seeResponseMatchesXmlSchema

      AssertableResponse seeResponseMatchesXmlSchema(Path filePath)
      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 fails
      net.bugreaper.core.exceptions.FileReaderException - if reading the file fails
    • seeResponseBodyElementsCount

      AssertableResponse seeResponseBodyElementsCount(int expectedCount)
      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