### Question:
MainController { @RequestMapping(value = "/init", method = RequestMethod.POST) public @ResponseBody InitResponse initGame() { LOGGER.info("INITIALIZING GAME"); Game game = new Game(); game.setPhase("joining"); return new InitResponse(gameRepository.save(game).getId()); }  @RequestMapping(value = "/init", method = RequestMethod.POST) @ResponseBody InitResponse initGame(); @RequestMapping(value = "/game/{gameId}/join", method = RequestMethod.POST) void joinGame(@PathVariable Long gameId, @RequestBody JoinRequest joinRequest); @RequestMapping(value = "/game/{gameId}/end", method = RequestMethod.POST) void endGame(@PathVariable Long gameId);  }### Answer:
@Test public void whenCallingInitGame_thenSaveGameIsCalledAndGameIdIsReturned() throws Exception { Game game = new Game(); game.setId(1L); doReturn(game).when(gameRepository).save(any()); System.out.println(mockMvc); mockMvc.perform(post("/init")) .andExpect(status().isOk()) .andExpect(content().json("{\"gameId\":1}")); InitResponse initResponse = mainControllerMock.initGame(); assertEquals((Long) 1L, initResponse.getGameId()); verify(gameRepository, times(2)).save(any()); }