Class ModelResultMatchers
java.lang.Object
org.springframework.test.web.servlet.result.ModelResultMatchers
Factory for assertions on the model.
 
An instance of this class is typically accessed via
 MockMvcResultMatchers.model().
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionAssert a model attribute value.<T> ResultMatcherAssert a model attribute value with the given HamcrestMatcher.attributeDoesNotExist(String... names) Assert the given model attributes do not exist.attributeErrorCount(String name, int expectedCount) Assert the given model attribute(s) have errors.attributeExists(String... names) Assert the given model attributes exist.attributeHasErrors(String... names) Assert the given model attribute(s) have errors.attributeHasFieldErrorCode(String name, String fieldName, String error) Assert a field error code for a model attribute using exact String match.attributeHasFieldErrorCode(String name, String fieldName, Matcher<? super String> matcher) Assert a field error code for a model attribute using aMatcher.attributeHasFieldErrors(String name, String... fieldNames) Assert the given model attribute field(s) have errors.attributeHasNoErrors(String... names) Assert the given model attribute(s) do not have errors.errorCount(int expectedCount) Assert the total number of errors in the model.Assert the model has errors.Assert the model has no errors.size(int size) Assert the number of model attributes.
- 
Constructor Details- 
ModelResultMatchersprotected ModelResultMatchers()Protected constructor. UseMockMvcResultMatchers.model().
 
- 
- 
Method Details- 
attributeAssert a model attribute value with the given HamcrestMatcher.
- 
attributeAssert a model attribute value.
- 
attributeExistsAssert the given model attributes exist.
- 
attributeDoesNotExistAssert the given model attributes do not exist.
- 
attributeErrorCountAssert the given model attribute(s) have errors.
- 
attributeHasErrorsAssert the given model attribute(s) have errors.
- 
attributeHasNoErrorsAssert the given model attribute(s) do not have errors.
- 
attributeHasFieldErrorsAssert the given model attribute field(s) have errors.
- 
attributeHasFieldErrorCodeAssert a field error code for a model attribute using exact String match.- Since:
- 4.1
 
- 
attributeHasFieldErrorCodepublic ResultMatcher attributeHasFieldErrorCode(String name, String fieldName, Matcher<? super String> matcher) Assert a field error code for a model attribute using aMatcher.- Since:
- 4.1
 
- 
errorCountAssert the total number of errors in the model.
- 
hasErrorsAssert the model has errors.
- 
hasNoErrorsAssert the model has no errors.
- 
sizeAssert the number of model attributes.
 
-