@PostMapping("/user")
public User create(@RequestBody User user){
System.out.println(user.toString());
user.setId(5l);
return user;
}
@Test
public void whenCreateSuccess() throws Exception {
String content = "{\"username\":\"fanqi\",\"password\":\"admin\",\"enabled\":\"1\"}";
mockMvc.perform(MockMvcRequestBuilders.post("/user")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.content(content))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").exists());
}