### Question:
UsersController { @GetMapping("/users") public List<User> getUsers() { return usersService.getUsers(); } UsersController(UsersService usersService); @GetMapping("/users") List<User> getUsers();  }### Answer:
@Test public void getUsersTest() throws Exception { List<User> users = Arrays.asList(new User("John"), new User("Peter")); when(usersService.getUsers()).thenReturn(users); mvc.perform(get("/users/") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(2))) .andExpect(jsonPath("$[0].name", equalTo("John"))); }