Class ResponseBodyAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>
org.assertj.core.api.AbstractArrayAssert<SELF,byte[],Byte>
org.assertj.core.api.AbstractByteArrayAssert<ResponseBodyAssert>
org.springframework.test.web.servlet.assertj.ResponseBodyAssert
- All Implemented Interfaces:
org.assertj.core.api.ArraySortedAssert<org.assertj.core.api.AbstractArrayAssert<ResponseBodyAssert,,byte[], Byte>, Byte> org.assertj.core.api.Assert<ResponseBodyAssert,,byte[]> org.assertj.core.api.Descriptable<ResponseBodyAssert>,org.assertj.core.api.EnumerableAssert<org.assertj.core.api.AbstractEnumerableAssert<ResponseBodyAssert,,byte[], Byte>, Byte> org.assertj.core.api.ExtensionPoints<ResponseBodyAssert,byte[]>
public class ResponseBodyAssert
extends org.assertj.core.api.AbstractByteArrayAssert<ResponseBodyAssert>
AssertJ
assertions that can be applied to
the response body.- Since:
- 6.2
- Author:
- Stephane Nicoll, Brian Clozel
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractByteArrayAssert
arraysFields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Method Summary
Modifier and TypeMethodDescriptionorg.assertj.core.api.AbstractStringAssert<?>asString()Override that uses the character encoding of theHttpServletResponseto convert the byte[] to a String, rather than the platform's default charset.Verify that the response body is equal to the givenString.json()Return a new assertion object that provides support for JSON assert comparisons against expected JSON input which can be loaded from the classpath.Return a new assertion object that provides support for JSON assert comparisons against expected JSON input which can be loaded from the classpath.jsonPath()Return a new assertion object that provides JSON path assertions on the response body.Methods inherited from class org.assertj.core.api.AbstractByteArrayAssert
asBase64Encoded, asHexString, asString, contains, contains, contains, contains, contains, containsAnyOf, containsAnyOf, containsAnyOf, containsExactly, containsExactly, containsExactly, containsExactlyInAnyOrder, containsExactlyInAnyOrder, containsExactlyInAnyOrder, containsOnly, containsOnly, containsOnly, containsOnlyOnce, containsOnlyOnce, containsOnlyOnce, containsSequence, containsSequence, containsSequence, containsSubsequence, containsSubsequence, containsSubsequence, doesNotContain, doesNotContain, doesNotContain, doesNotContain, doesNotContain, doesNotHaveDuplicates, encodedAsBase64, endsWith, endsWith, endsWith, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmpty, isSorted, isSortedAccordingTo, startsWith, startsWith, startsWith, usingDefaultElementComparator, usingElementComparatorMethods inherited from class org.assertj.core.api.AbstractEnumerableAssert
hasSameSizeAs, inBinary, inHexadecimalMethods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, 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, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Method Details
-
jsonPath
Return a new assertion object that provides JSON path assertions on the response body. -
json
Return a new assertion object that provides support for JSON assert comparisons against expected JSON input which can be loaded from the classpath.This method only supports absolute locations for JSON documents loaded from the classpath. Consider using
json(Class)to load JSON documents relative to a given class.Example:
// Check that the response is strictly equal to the content of // "/com/acme/web/person/person-created.json": assertThat(...).body().json() .isStrictlyEqualToJson("/com/acme/web/person/person-created.json"); -
json
Return a new assertion object that provides support for JSON assert comparisons against expected JSON input which can be loaded from the classpath.Locations for JSON documents can be absolute using a leading slash, or relative to the given
resourceLoadClass.Example:
// Check that the response is strictly equal to the content of the // specified file located in the same package as the PersonController: assertThat(...).body().json(PersonController.class) .isStrictlyEqualToJson("person-created.json");- Parameters:
resourceLoadClass- the class used to load relative JSON documents- See Also:
-
isEqualTo
Verify that the response body is equal to the givenString.Converts the actual byte array to a String using the character encoding of the
HttpServletResponse.- Parameters:
expected- the expected content of the response body- See Also:
-
asString
public org.assertj.core.api.AbstractStringAssert<?> asString()Override that uses the character encoding of theHttpServletResponseto convert the byte[] to a String, rather than the platform's default charset.- Specified by:
asStringin interfaceorg.assertj.core.api.Assert<ResponseBodyAssert,byte[]> - Overrides:
asStringin classorg.assertj.core.api.AbstractByteArrayAssert<ResponseBodyAssert>
-