spring-framework / org.springframework.test.web / ModelAndViewAssert

ModelAndViewAssert

abstract class ModelAndViewAssert

A collection of assertions intended to simplify testing scenarios dealing with Spring Web MVC org.springframework.web.servlet.ModelAndView objects.

Intended for use with JUnit 4 and TestNG. All assert*() methods throw AssertionErrors.

Author
Sam Brannen

Author
Alef Arendsen

Author
Bram Smeets

Since
2.5

See Also
org.springframework.web.servlet.ModelAndView

Constructors

<init>

ModelAndViewAssert()

A collection of assertions intended to simplify testing scenarios dealing with Spring Web MVC org.springframework.web.servlet.ModelAndView objects.

Intended for use with JUnit 4 and TestNG. All assert*() methods throw AssertionErrors.

Functions

assertAndReturnModelAttributeOfType

open static fun <T : Any> assertAndReturnModelAttributeOfType(mav: ModelAndView, modelName: String, expectedType: Class<T>): T

Checks whether the model value under the given modelName exists and checks it type, based on the expectedType. If the model entry exists and the type matches, the model value is returned.

assertCompareListModelAttribute

open static fun assertCompareListModelAttribute(mav: ModelAndView, modelName: String, expectedList: MutableList<Any?>): Unit

Compare each individual entry in a list, without first sorting the lists.

assertModelAttributeAvailable

open static fun assertModelAttributeAvailable(mav: ModelAndView, modelName: String): Unit

Assert whether or not a model attribute is available.

assertModelAttributeValue

open static fun assertModelAttributeValue(mav: ModelAndView, modelName: String, expectedValue: Any): Unit

Compare a given expectedValue to the value from the model bound under the given modelName.

assertModelAttributeValues

open static fun assertModelAttributeValues(mav: ModelAndView, expectedModel: MutableMap<String, Any>): Unit

Inspect the expectedModel to see if all elements in the model appear and are equal.

assertSortAndCompareListModelAttribute

open static fun assertSortAndCompareListModelAttribute(mav: ModelAndView, modelName: String, expectedList: MutableList<Any?>, comparator: Comparator<Any>): Unit

Compare each individual entry in a list after having sorted both lists (optionally using a comparator).

assertViewName

open static fun assertViewName(mav: ModelAndView, expectedName: String): Unit

Check to see if the view name in the ModelAndView matches the given expectedName.