Package org.springframework.test.web.servlet.assertj

# Class MvcTestResultAssert

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<MvcTestResultAssert,MvcTestResult>
org.springframework.test.web.servlet.assertj.MvcTestResultAssert

All Implemented Interfaces:
  `org.assertj.core.api.Assert<MvcTestResultAssert,MvcTestResult>`, `org.assertj.core.api.Descriptable<MvcTestResultAssert>`, `org.assertj.core.api.ExtensionPoints<MvcTestResultAssert,MvcTestResult>`

public class MvcTestResultAssert extends AbstractMockHttpServletResponseAssert<MvcTestResultAssert,MvcTestResult>
AssertJ assertions that can be applied to `MvcTestResult`.

Since:
  6.2
Author:
  Stephane Nicoll, Brian Clozel

## Field Summary

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

`actual, info, myself, objects, throwUnsupportedExceptionOnEquals`

## Method Summary

Modifier and Type
Method
Description
`MvcTestResultAssert`
`apply(ResultHandler resultHandler)`
Apply the given `ResultHandler` to the actual MVC result.
`CookieMapAssert`
`cookies()`
Return a new assertion object that uses the response's cookies as the object to test.
`MvcTestResultAssert`
`debug()`
Print `MvcResult` details to `System.out`.
`MvcTestResultAssert`
`debug(OutputStream stream)`
Print `MvcResult` details to the supplied `OutputStream`.
`MvcTestResultAssert`
`debug(Writer writer)`
Print `MvcResult` details to the supplied `Writer`.
`MvcTestResultAssert`
`doesNotHaveFailed()`
Verify that the request has not failed.
`org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable>`
`failure()`
Verify that the request has failed and return a new assertion object that uses the failure as the object to test.
`org.assertj.core.api.MapAssert<String,Object>`
`flash()`
Return a new assertion object that uses the "output" flash attributes saved during request processing as the object to test.
`protected MvcResult`
`getMvcResult()`
`protected MockHttpServletResponse`
`getResponse()`
Provide the response to use if it is available.
`HandlerResultAssert`
`handler()`
Return a new assertion object that uses the handler as the object to test.
`MvcTestResultAssert`
`hasFailed()`
Verify that the request has failed.
`MvcTestResultAssert`
`hasViewName(String viewName)`
Verify that a `ModelAndView` is available with a view name equal to the given one.
`MvcTestResultAssert`
`matches(ResultMatcher resultMatcher)`
Verify that the actual MVC result matches the given `ResultMatcher`.
`ModelAssert`
`model()`
Verify that a `ModelAndView` is available and return a new assertion object that uses the model as the object to test.
`AbstractMockHttpServletRequestAssert<?>`
`request()`
Return a new assertion object that uses the `MockHttpServletRequest` as the object to test.
`org.assertj.core.api.AbstractStringAssert<?>`
`viewName()`
Verify that a `ModelAndView` is available and return a new assertion object that uses the view name as the object to test.

### Methods inherited from class org.springframework.test.web.servlet.assertj.AbstractMockHttpServletResponseAssert

`body, bodyJson, bodyText, forwardedUrl, hasBodyTextEqualTo, hasErrorMessage, hasForwardedUrl, hasRedirectedUrl, redirectedUrl`

### Methods inherited from class org.springframework.test.web.servlet.assertj.AbstractHttpServletResponseAssert

`containsHeader, contentType, doesNotContainHeader, hasContentType, hasContentType, hasContentTypeCompatibleWith, hasContentTypeCompatibleWith, hasHeader, hasStatus, hasStatus, hasStatus1xxInformational, hasStatus2xxSuccessful, hasStatus3xxRedirection, hasStatus4xxClientError, hasStatus5xxServerError, hasStatusOk, headers`

### 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

`actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, 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, usingEquals, usingEquals, 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`

## Method Details

### getResponse

protected MockHttpServletResponse getResponse()
Description copied from class: `AbstractHttpServletResponseAssert`
Provide the response to use if it is available.

Throws an `AssertionError` if the request has failed to process, and the response is not available.

Specified by:
  `getResponse` in class `AbstractHttpServletResponseAssert<MockHttpServletResponse,MvcTestResultAssert,MvcTestResult>`
Returns:
  the response to use

### failure

public org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> failure()
Verify that the request has failed and return a new assertion object that uses the failure as the object to test.

### request

public AbstractMockHttpServletRequestAssert<?> request()
Return a new assertion object that uses the `MockHttpServletRequest` as the object to test.

### cookies

public CookieMapAssert cookies()
Return a new assertion object that uses the response's cookies as the object to test.

### handler

public HandlerResultAssert handler()
Return a new assertion object that uses the handler as the object to test.

For a method invocation on a controller, this is a relative method handler.

Example:

     // Check that a GET to "/greet" is invoked on a "handleGreet" method name
     assertThat(mvc.perform(get("/greet")).handler().method().hasName("handleGreet");

### model

public ModelAssert model()
Verify that a `ModelAndView` is available and return a new assertion object that uses the model as the object to test.

### viewName

public org.assertj.core.api.AbstractStringAssert<?> viewName()
Verify that a `ModelAndView` is available and return a new assertion object that uses the view name as the object to test.

See Also:
  - `hasViewName(String)`

### flash

public org.assertj.core.api.MapAssert<String,Object> flash()
Return a new assertion object that uses the "output" flash attributes saved during request processing as the object to test.

### debug

public MvcTestResultAssert debug()
Print `MvcResult` details to `System.out`.

You must call it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.

### debug

public MvcTestResultAssert debug(OutputStream stream)
Print `MvcResult` details to the supplied `OutputStream`.

You must call it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.

### debug

public MvcTestResultAssert debug(Writer writer)
Print `MvcResult` details to the supplied `Writer`.

You must call it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.

### hasFailed

public MvcTestResultAssert hasFailed()
Verify that the request has failed.

### doesNotHaveFailed

public MvcTestResultAssert doesNotHaveFailed()
Verify that the request has not failed.

### matches

public MvcTestResultAssert matches(ResultMatcher resultMatcher)
Verify that the actual MVC result matches the given `ResultMatcher`.

Parameters:
  `resultMatcher` - the result matcher to invoke

### apply

public MvcTestResultAssert apply(ResultHandler resultHandler)
Apply the given `ResultHandler` to the actual MVC result.

Parameters:
  `resultHandler` - the result matcher to invoke

### hasViewName

public MvcTestResultAssert hasViewName(String viewName)
Verify that a `ModelAndView` is available with a view name equal to the given one.

For more advanced assertions, consider using `viewName()`.

Parameters:
  `viewName` - the expected view name

### getMvcResult

protected MvcResult getMvcResult()