### Question:
MainController { @RequestMapping(value = "/game/{gameId}/end", method = RequestMethod.POST) public void endGame(@PathVariable Long gameId) throws Exception { Game game = repoUtil.findGameById(gameId); if (game != null) { gameRepository.delete(game); return; } throw new Exception("Game never existed"); }  @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 givenGameIdExists_whenCallingEndGame_thenCallDeleteGame() throws Exception { Game game = new Game(); doReturn(game).when(repoUtil).findGameById(1L); mockMvc.perform(post("/game/1/end")) .andExpect(status().isOk()); mainControllerMock.endGame(1L); verify(gameRepository, times(2)).delete(game); }