Class AbstractMockHttpServletResponseAssert<SELF extends AbstractMockHttpServletResponseAssert<SELF,ACTUAL>,ACTUAL>

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<SELF,ACTUAL>
org.springframework.test.web.servlet.assertj.AbstractHttpServletResponseAssert<MockHttpServletResponse,SELF,ACTUAL>
org.springframework.test.web.servlet.assertj.AbstractMockHttpServletResponseAssert<SELF,ACTUAL>
Type Parameters:
SELF - the type of assertions
ACTUAL - the type of the object to assert
All Implemented Interfaces:
org.assertj.core.api.Assert<SELF,ACTUAL>, org.assertj.core.api.Descriptable<SELF>, org.assertj.core.api.ExtensionPoints<SELF,ACTUAL>
Direct Known Subclasses:
MvcTestResultAssert

public abstract class AbstractMockHttpServletResponseAssert<SELF extends AbstractMockHttpServletResponseAssert<SELF,ACTUAL>,ACTUAL> extends AbstractHttpServletResponseAssert<MockHttpServletResponse,SELF,ACTUAL>
Since:
6.2
Author:
Stephane Nicoll
  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.assertj.core.api.AbstractByteArrayAssert<?>
    Return a new assertion object that uses the response body as the object to test.
    Return a new assertion object that uses the response body converted to text as the object to test.
    org.assertj.core.api.AbstractStringAssert<?>
    Return a new assertion object that uses the response body converted to text as the object to test.
    Return a new assertion object that uses the forwarded URL as the object to test.
    Verify that the response body is equal to the given value.
    hasForwardedUrl(String forwardedUrl)
    Verify that the forwarded URL is equal to the given value.
    hasRedirectedUrl(String redirectedUrl)
    Verify that the redirected URL is equal to the given value.
    Return a new assertion object that uses the redirected URL as the object to test.

    Methods inherited from class org.assertj.core.api.AbstractObjectAssert

    as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison

    Methods inherited from class org.assertj.core.api.AbstractAssert

    areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, describedAs, describedAs
  • Constructor Details

  • Method Details

    • bodyText

      public org.assertj.core.api.AbstractStringAssert<?> bodyText()
      Return a new assertion object that uses the response body converted to text as the object to test.

      Examples:

      
       // Check that the response body is equal to "Hello World":
       assertThat(response).bodyText().isEqualTo("Hello World");
       
    • bodyJson

      public AbstractJsonContentAssert<?> bodyJson()
      Return a new assertion object that uses the response body converted to text as the object to test. Compared to bodyText(), the assertion object provides dedicated JSON support.

      Examples:

      
       // Check that the response body is strictly equal to the content of
       // "/com/acme/sample/person-created.json":
       assertThat(response).bodyJson()
               .isStrictlyEqualToJson("/com/acme/sample/person-created.json");
      
       // Check that the response is strictly equal to the content of the
       // specified file located in the same package as the PersonController:
       assertThat(response).bodyJson().withResourceLoadClass(PersonController.class)
               .isStrictlyEqualToJson("person-created.json");
       
      The returned assert object also supports JSON path expressions.

      Examples:

      
       // Check that the JSON document does not have an "error" element
       assertThat(response).bodyJson().doesNotHavePath("$.error");
      
       // Check that the JSON document as a top level "message" element
       assertThat(response).bodyJson()
               .extractingPath("$.message").asString().isEqualTo("hello");
       
    • body

      public org.assertj.core.api.AbstractByteArrayAssert<?> body()
      Return a new assertion object that uses the response body as the object to test.
      See Also:
    • forwardedUrl

      public UriAssert forwardedUrl()
      Return a new assertion object that uses the forwarded URL as the object to test. If a simple equality check is required, consider using hasForwardedUrl(String) instead.

      Example:

      
       // Check that the forwarded URL starts with "/orders/":
       assertThat(response).forwardedUrl().matchPattern("/orders/*);
       
    • redirectedUrl

      public UriAssert redirectedUrl()
      Return a new assertion object that uses the redirected URL as the object to test. If a simple equality check is required, consider using hasRedirectedUrl(String) instead.

      Example:

      
       // Check that the redirected URL starts with "/orders/":
       assertThat(response).redirectedUrl().matchPattern("/orders/*);
       
    • hasBodyTextEqualTo

      public SELF hasBodyTextEqualTo(String bodyText)
      Verify that the response body is equal to the given value.
    • hasForwardedUrl

      public SELF hasForwardedUrl(@Nullable String forwardedUrl)
      Verify that the forwarded URL is equal to the given value.
      Parameters:
      forwardedUrl - the expected forwarded URL (can be null)
    • hasRedirectedUrl

      public SELF hasRedirectedUrl(@Nullable String redirectedUrl)
      Verify that the redirected URL is equal to the given value.
      Parameters:
      redirectedUrl - the expected redirected URL (can be null)