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 Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractStatusAssertions(E exchangeResult, R responseSpec)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Subclasses must implement this to assert with diagnostics.
    protected E
    Return the exchange result.
    protected abstract org.springframework.http.HttpStatusCode
    Subclasses must implement this to provide access to the response status.
    Assert the response status code is in the 1xx range.
    Assert the response status code is in the 2xx range.
    Assert the response status code is in the 3xx range.
    Assert the response status code is in the 4xx range.
    Assert the response status code is in the 5xx range.
    Assert the response status code is HttpStatus.ACCEPTED (202).
    Assert the response status code is HttpStatus.BAD_REQUEST (400).
    Assert the response status code is HttpStatus.CREATED (201).
    isEqualTo(int status)
    Assert the response status as an integer.
    isEqualTo(org.springframework.http.HttpStatusCode status)
    Assert the response status as an HttpStatusCode.
    Assert the response status code is HttpStatus.FORBIDDEN (403).
    Assert the response status code is HttpStatus.FOUND (302).
    Assert the response status code is HttpStatus.NO_CONTENT (204).
    Assert the response status code is HttpStatus.NOT_FOUND (404).
    Assert the response status code is HttpStatus.NOT_MODIFIED (304).
    Assert the response status code is HttpStatus.OK (200).
    Assert the response status code is HttpStatus.PERMANENT_REDIRECT (308).
    Assert the response status code is HttpStatus.SEE_OTHER (303).
    Assert the response status code is HttpStatus.TEMPORARY_REDIRECT (307).
    Assert the response status code is HttpStatus.UNAUTHORIZED (401).
    Assert the response error message.
    value(Consumer<Integer> consumer)
    Consume the response status value as an integer.
    value(Matcher<? super Integer> matcher)
    Match the response status value with a Hamcrest matcher.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractStatusAssertions

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

    • getExchangeResult

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

      protected abstract org.springframework.http.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(org.springframework.http.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