Class AbstractStatusAssertions<E,R>

java.lang.Object
org.springframework.test.web.support.AbstractStatusAssertions<E,R>
Type Parameters:
E - the type of the exchange result
R - the type of the response spec
Direct Known Subclasses:
StatusAssertions, StatusAssertions

public abstract class AbstractStatusAssertions<E,R> extends Object
Assertions on the response status.
Since:
7.0
Author:
Rob Worsnop, Rossen Stoyanchev
  • Constructor Details

    • AbstractStatusAssertions

      protected AbstractStatusAssertions(E exchangeResult, R responseSpec)
  • Method Details

    • getExchangeResult

      protected E getExchangeResult()
      Return the exchange result.
    • getStatus

      protected abstract HttpStatusCode getStatus()
      Subclasses must implement this to provide access to the response status.
    • assertWithDiagnostics

      protected abstract void assertWithDiagnostics(Runnable assertion)
      Subclasses must implement this to assert with diagnostics.
    • isEqualTo

      public R isEqualTo(HttpStatusCode status)
      Assert the response status as an HttpStatusCode.
    • isEqualTo

      public R isEqualTo(int status)
      Assert the response status as an integer.
    • isOk

      public R isOk()
      Assert the response status code is HttpStatus.OK (200).
    • isCreated

      public R isCreated()
      Assert the response status code is HttpStatus.CREATED (201).
    • isAccepted

      public R isAccepted()
      Assert the response status code is HttpStatus.ACCEPTED (202).
    • isNoContent

      public R isNoContent()
      Assert the response status code is HttpStatus.NO_CONTENT (204).
    • isFound

      public R isFound()
      Assert the response status code is HttpStatus.FOUND (302).
    • isSeeOther

      public R isSeeOther()
      Assert the response status code is HttpStatus.SEE_OTHER (303).
    • isNotModified

      public R isNotModified()
      Assert the response status code is HttpStatus.NOT_MODIFIED (304).
    • isTemporaryRedirect

      public R isTemporaryRedirect()
      Assert the response status code is HttpStatus.TEMPORARY_REDIRECT (307).
    • isPermanentRedirect

      public R isPermanentRedirect()
      Assert the response status code is HttpStatus.PERMANENT_REDIRECT (308).
    • isBadRequest

      public R isBadRequest()
      Assert the response status code is HttpStatus.BAD_REQUEST (400).
    • isUnauthorized

      public R isUnauthorized()
      Assert the response status code is HttpStatus.UNAUTHORIZED (401).
    • isForbidden

      public R isForbidden()
      Assert the response status code is HttpStatus.FORBIDDEN (403).
    • isNotFound

      public R isNotFound()
      Assert the response status code is HttpStatus.NOT_FOUND (404).
    • reasonEquals

      public R reasonEquals(String reason)
      Assert the response error message.
    • is1xxInformational

      public R is1xxInformational()
      Assert the response status code is in the 1xx range.
    • is2xxSuccessful

      public R is2xxSuccessful()
      Assert the response status code is in the 2xx range.
    • is3xxRedirection

      public R is3xxRedirection()
      Assert the response status code is in the 3xx range.
    • is4xxClientError

      public R is4xxClientError()
      Assert the response status code is in the 4xx range.
    • is5xxServerError

      public R is5xxServerError()
      Assert the response status code is in the 5xx range.
    • value

      public R value(Matcher<? super Integer> matcher)
      Match the response status value with a Hamcrest matcher.
      Parameters:
      matcher - the matcher to use
    • value

      public R value(Consumer<Integer> consumer)
      Consume the response status value as an integer.
      Parameters:
      consumer - the consumer to use
      Since:
      5.1