### Question:
PlayerServiceImpl implements PlayerService { @Override public void reloadAI(String id) { lock.writeLock().lock(); try { PlayerGame playerGame = playerGames.get(id); registerAI(id, playerGame.getRoomName(), playerGame.getGameType()); } finally { lock.writeLock().unlock(); } }  @PostConstruct void init(); @Override Player register(String id, String ip, String roomName, String gameName); @Override void reloadAI(String id); @Override Player register(PlayerSave save); @Override void tick(); @Override List<Player> getAll(); @Override List<Player> getAll(String gameName); @Override void remove(String id); @Override void updateAll(List<PlayerInfo> players); @Override void update(Player player); @Override // TODO test me void loadSaveForAll(String gameName, String newSave); @Override boolean contains(String id); @Override Player get(String id); @Override void removeAll(); @Override void removeAll(String roomName); @Override Joystick getJoystick(String id); @Override void closeRegistration(); @Override boolean isRegistrationOpened(); @Override void openRegistration(); @Override void cleanAllScores(); @Override void cleanAllScores(String roomName); @Override void reloadAllRooms(); @Override void reloadAllRooms(String roomName); @Override Player getRandom(String gameType); @Override GameType getAnyGameWithPlayers();  }### Answer:
@Test public void testReloadAI() { WebSocketRunner.ATTEMPTS = 0; WebSocketRunner.TIMEOUT = 100; when(gameType.getAI()).thenReturn((Class)AISolverStub.class); when(gameType.getBoard()).thenReturn((Class)BoardStub.class); String gameName = createPlayer(VASYA).getGameName(); verify(gameType, times(1)).getAI(); verify(gameType, times(1)).getBoard(); playerService.reloadAI(VASYA); verify(gameType, times(2)).getAI(); verify(gameType, times(2)).getBoard(); PlayerGame playerGame = playerGames.get(VASYA); assertEquals(gameName, playerGame.getPlayer().getGameName()); Player player = playerGame.getPlayer(); assertEquals(VASYA, player.getId()); assertNotNull(VASYA, player.getAi()); }