@Test public void testSubmit() throws Exception { mockMvc.perform( post("/scores/submit") .contentType(MediaType.APPLICATION_JSON) .content("{\"name\": \"a\", \"score\": 100}") ).andExpect(status().isOk()); }
@PostMapping(value = "/scores/*", consumes = "application/json") public void submit(@RequestBody LeaderboardEntry score) { leaderboardService.recordScore(score.name(), score.score()); }
LeaderboardController { @PostMapping(value = "/scores/*", consumes = "application/json") public void submit(@RequestBody LeaderboardEntry score) { leaderboardService.recordScore(score.name(), score.score()); } }
LeaderboardController { @PostMapping(value = "/scores/*", consumes = "application/json") public void submit(@RequestBody LeaderboardEntry score) { leaderboardService.recordScore(score.name(), score.score()); } LeaderboardController(LeaderboardService leaderboardService); }
LeaderboardController { @PostMapping(value = "/scores/*", consumes = "application/json") public void submit(@RequestBody LeaderboardEntry score) { leaderboardService.recordScore(score.name(), score.score()); } LeaderboardController(LeaderboardService leaderboardService); @GetMapping("/top/{k}") List<LeaderboardEntry> top10(@PathVariable int k); @PostMapping(value = "/scores/*", consumes = "application/json") void submit(@RequestBody LeaderboardEntry score); }
LeaderboardController { @PostMapping(value = "/scores/*", consumes = "application/json") public void submit(@RequestBody LeaderboardEntry score) { leaderboardService.recordScore(score.name(), score.score()); } LeaderboardController(LeaderboardService leaderboardService); @GetMapping("/top/{k}") List<LeaderboardEntry> top10(@PathVariable int k); @PostMapping(value = "/scores/*", consumes = "application/json") void submit(@RequestBody LeaderboardEntry score);  }