PlayerService { public void savePlayerGame(String name) { lock.readLock().lock(); try { Player player = getPlayer(name); if (player != null) { saver.saveGame(player); } } finally { lock.readLock().unlock(); } }  void savePlayerGame(String name); void loadPlayerGame(String name); Player addNewPlayer(final String name, final String callbackUrl, TContext context); void nextStepForAllGames(); void setSendScreenUpdates(boolean sendScreenUpdates); List<Player> getPlayers(); boolean alreadyRegistered(String playerName); Player findPlayer(String playerName); void updatePlayer(Player player); void updatePlayers(List<PlayerInfo> players); void clear(); Player findPlayerByIp(String ip); void removePlayerByIp(String ip); void removePlayerByName(String name); List<PlayerInfo> getPlayersGames();  }
@Test public void shouldNotSavePlayerWhenNotExists() { playerService.savePlayerGame("vasia"); verifyNoMoreInteractions(saver); }
@Test public void shouldSavePlayerWhenExists() { Player player = createPlayer("vasia"); playerService.savePlayerGame("vasia"); verify(saver).saveGame(player); }