Java Code Examples for org.springframework.util.MultiValueMap#setAll()

The following examples show how to use org.springframework.util.MultiValueMap#setAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserControllerTest.java    From springboot-learning-example with Apache License 2.0 6 votes vote down vote up
@Test
public void postUser() throws Exception {
    User user = createUser();
    assertNotNull(user);

    MultiValueMap parameters = new LinkedMultiValueMap<String, String>();
    Map<String, String> maps = objectMapper.convertValue(user, new TypeReference<Map<String, String>>() {
    });
    parameters.setAll(maps);

    mockMvc.perform(post("/users/create").params(parameters))
            .andDo(print())
            .andExpect(status().is(HttpServletResponse.SC_FOUND))
            .andDo(print())
            .andExpect(view().name("redirect:/users/"))
            .andDo(print())
            .andReturn();
}
 
Example 2
Source File: UserControllerTest.java    From springboot-learning-example with Apache License 2.0 6 votes vote down vote up
@Test
public void putUser() throws Exception {
    User user = createUser();
    assertNotNull(user);

    MultiValueMap parameters = new LinkedMultiValueMap<String, String>();
    Map<String, String> maps = objectMapper.convertValue(user, new TypeReference<Map<String, String>>() {
    });
    parameters.setAll(maps);

    mockMvc.perform(post("/users/update").params(parameters))
            .andDo(print())
            .andExpect(status().is(HttpServletResponse.SC_FOUND))
            .andDo(print())
            .andExpect(view().name("redirect:/users/"))
            .andDo(print())
            .andReturn();
}