ModelResultMatchers (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.test.web.servlet.result

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

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ModelResultMatchers()` Protected constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> ResultMatcher` | `attribute(String name, org.hamcrest.Matcher<T> matcher)` Assert a model attribute value with the given Hamcrest `Matcher`.
    `ResultMatcher` | `attribute(String name, Object value)` Assert a model attribute value.
    `ResultMatcher` | `attributeErrorCount(String name, int expectedCount)` Assert the given model attribute(s) have errors.
    `ResultMatcher` | `attributeExists(String... names)` Assert the given model attributes exist.
    `ResultMatcher` | `attributeHasErrors(String... names)` Assert the given model attribute(s) have errors.
    `ResultMatcher` | `attributeHasFieldErrors(String name, String... fieldNames)` Assert the given model attribute field(s) have errors.
    `ResultMatcher` | `attributeHasNoErrors(String... names)` Assert the given model attribute(s) do not have errors.
    `<T> ResultMatcher` | `errorCount(int expectedCount)` Assert the total number of errors in the model.
    `<T> ResultMatcher` | `hasErrors()` Assert the model has errors.
    `<T> ResultMatcher` | `hasNoErrors()` Assert the model has no errors.
    `<T> ResultMatcher` | `size(int size)` Assert the number of model attributes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ModelResultMatchers

          protected ModelResultMatchers()

      Protected constructor. Use `MockMvcResultMatchers.model()`.

  - ### Method Detail

    - #### attribute

          public <T> ResultMatcher attribute(String name,
                                    org.hamcrest.Matcher<T> matcher)

      Assert a model attribute value with the given Hamcrest `Matcher`.

    - #### attribute

          public ResultMatcher attribute(String name,
                                Object value)

      Assert a model attribute value.

    - #### attributeExists

          public ResultMatcher attributeExists(String... names)

      Assert the given model attributes exist.

    - #### attributeErrorCount

          public ResultMatcher attributeErrorCount(String name,
                                          int expectedCount)

      Assert the given model attribute(s) have errors.

    - #### attributeHasErrors

          public ResultMatcher attributeHasErrors(String... names)

      Assert the given model attribute(s) have errors.

    - #### attributeHasNoErrors

          public ResultMatcher attributeHasNoErrors(String... names)

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

    - #### attributeHasFieldErrors

          public ResultMatcher attributeHasFieldErrors(String name,
                                              String... fieldNames)

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

    - #### errorCount

          public <T> ResultMatcher errorCount(int expectedCount)

      Assert the total number of errors in the model.

    - #### hasErrors

          public <T> ResultMatcher hasErrors()

      Assert the model has errors.

    - #### hasNoErrors

          public <T> ResultMatcher hasNoErrors()

      Assert the model has no errors.

    - #### size

          public <T> ResultMatcher size(int size)

      Assert the number of model attributes.