spring-framework / org.springframework.test.web.servlet.result / ModelResultMatchers

ModelResultMatchers

open class ModelResultMatchers

Factory for assertions on the model.

An instance of this class is typically accessed via MockMvcResultMatchers#model.

Author
Rossen Stoyanchev

Since
3.2

Functions

attribute

open fun <T : Any> attribute(name: String, matcher: Matcher<T>): ResultMatcher

Assert a model attribute value with the given Hamcrest Matcher.

open fun attribute(name: String, value: Any): ResultMatcher

Assert a model attribute value.

attributeDoesNotExist

open fun attributeDoesNotExist(vararg names: String): ResultMatcher

Assert the given model attributes do not exist

attributeErrorCount

open fun attributeErrorCount(name: String, expectedCount: Int): ResultMatcher

Assert the given model attribute(s) have errors.

attributeExists

open fun attributeExists(vararg names: String): ResultMatcher

Assert the given model attributes exist.

attributeHasErrors

open fun attributeHasErrors(vararg names: String): ResultMatcher

Assert the given model attribute(s) have errors.

attributeHasFieldErrorCode

open fun attributeHasFieldErrorCode(name: String, fieldName: String, error: String): ResultMatcher

Assert a field error code for a model attribute using exact String match.

open fun <T : Any> attributeHasFieldErrorCode(name: String, fieldName: String, matcher: Matcher<in String>): ResultMatcher

Assert a field error code for a model attribute using a org.hamcrest.Matcher.

attributeHasFieldErrors

open fun attributeHasFieldErrors(name: String, vararg fieldNames: String): ResultMatcher

Assert the given model attribute field(s) have errors.

attributeHasNoErrors

open fun attributeHasNoErrors(vararg names: String): ResultMatcher

Assert the given model attribute(s) do not have errors.

errorCount

open fun <T : Any> errorCount(expectedCount: Int): ResultMatcher

Assert the total number of errors in the model.

hasErrors

open fun <T : Any> hasErrors(): ResultMatcher

Assert the model has errors.

hasNoErrors

open fun <T : Any> hasNoErrors(): ResultMatcher

Assert the model has no errors.

size

open fun <T : Any> size(size: Int): ResultMatcher

Assert the number of model attributes.