LadderController { @GetMapping("/ladder") public List<EloPlayer> getLadder(@RequestParam(defaultValue = DEFAULT_LADDER_SIZE) int size) { return userRepository.findAll().stream() .map(EloPlayer::new) .sorted((u1, u2) -> u2.getRating() - u1.getRating()) .limit(size) .collect(Collectors.toCollection(ArrayList::new)); }  @GetMapping("/ladder") List<EloPlayer> getLadder(@RequestParam(defaultValue = DEFAULT_LADDER_SIZE) int size);  }
@Test public void getLadder() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/ladder").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect( content() .string( equalTo( "[{\"username\":\"u2\",\"rating\":2000},{\"username\":\"u3\",\"rating\":1700},{\"username\":\"u1\",\"rating\":1500},{\"username\":\"u4\",\"rating\":800}]"))); }