Class ModelResultMatchers

java.lang.Object
org.springframework.test.web.servlet.result.ModelResultMatchers

public class ModelResultMatchers extends Object
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 Details

  • Method Details

    • attribute

      public&nbsp;<T>&nbsp;ResultMatcher&nbsp;attribute(string&nbsp;name, Matcher<? super T>&nbsp;matcher)
      Assert a model attribute value with the given Hamcrest Matcher.
    • attribute

      public&nbsp;ResultMatcher&nbsp;attribute(string&nbsp;name, @Nullable Object&nbsp;value)
      Assert a model attribute value.
    • attributeExists

      public&nbsp;ResultMatcher&nbsp;attributeExists(string...&nbsp;names)
      Assert the given model attributes exist.
    • attributeDoesNotExist

      public&nbsp;ResultMatcher&nbsp;attributeDoesNotExist(string...&nbsp;names)
      Assert the given model attributes do not exist.
    • attributeErrorCount

      public&nbsp;ResultMatcher&nbsp;attributeErrorCount(string&nbsp;name, int&nbsp;expectedCount)
      Assert the given model attribute(s) have errors.
    • attributeHasErrors

      public&nbsp;ResultMatcher&nbsp;attributeHasErrors(string...&nbsp;names)
      Assert the given model attribute(s) have errors.
    • attributeHasNoErrors

      public&nbsp;ResultMatcher&nbsp;attributeHasNoErrors(string...&nbsp;names)
      Assert the given model attribute(s) do not have errors.
    • attributeHasFieldErrors

      public&nbsp;ResultMatcher&nbsp;attributeHasFieldErrors(string&nbsp;name, string...&nbsp;fieldNames)
      Assert the given model attribute field(s) have errors.
    • attributeHasFieldErrorCode

      public&nbsp;ResultMatcher&nbsp;attributeHasFieldErrorCode(string&nbsp;name, string&nbsp;fieldName, string&nbsp;error)
      Assert a field error code for a model attribute using exact string match.
      since:
      4.1
    • attributeHasFieldErrorCode

      public&nbsp;ResultMatcher&nbsp;attributeHasFieldErrorCode(string&nbsp;name, string&nbsp;fieldName, Matcher<? super string>&nbsp;matcher)
      Assert a field error code for a model attribute using a Matcher.
      since:
      4.1
    • errorCount

      public&nbsp;ResultMatcher&nbsp;errorCount(int&nbsp;expectedCount)
      Assert the total number of errors in the model.
    • hasErrors

      public&nbsp;ResultMatcher&nbsp;hasErrors()
      Assert the model has errors.
    • hasNoErrors

      public&nbsp;ResultMatcher&nbsp;hasNoErrors()
      Assert the model has no errors.
    • size

      public&nbsp;ResultMatcher&nbsp;size(int&nbsp;size)
      Assert the number of model attributes.