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

org.springframework.test.web.servlet

## Interface ResultActions

-     public interface ResultActions

  Allows applying actions, such as expectations, on the result of an executed request.

  See static factory methods in `org.springframework.test.web.server.result.MockMvcResultMatchers` `org.springframework.test.web.server.result.MockMvcResultHandlers`

  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ResultActions` | `andDo(ResultHandler handler)` Provide a general action.
    `ResultActions` | `andExpect(ResultMatcher matcher)` Provide an expectation.
    `MvcResult` | `andReturn()` Return the result of the executed request for direct access to the results.

- - ### Method Detail

    - #### andExpect

          ResultActions andExpect(ResultMatcher matcher)
                                  throws Exception

      Provide an expectation. For example:

           static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*

           mockMvc.perform(get("/person/1"))
             .andExpect(status.isOk())
             .andExpect(content().mimeType(MediaType.APPLICATION_JSON))
             .andExpect(jsonPath("$.person.name").equalTo("Jason"));

           mockMvc.perform(post("/form"))
             .andExpect(status.isOk())
             .andExpect(redirectedUrl("/person/1"))
             .andExpect(model().size(1))
             .andExpect(model().attributeExists("person"))
             .andExpect(flash().attributeCount(1))
             .andExpect(flash().attribute("message", "success!"));

      Throws:
        `Exception`

    - #### andDo

          ResultActions andDo(ResultHandler handler)
                              throws Exception

      Provide a general action. For example:

           static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*

           mockMvc.perform(get("/form")).andDo(print());

      Throws:
        `Exception`

    - #### andReturn

          MvcResult andReturn()

      Return the result of the executed request for direct access to the results.
      Returns:
        the result of the request