### Question:
PlayerServiceImpl implements PlayerService { @Override public void updateAll(List<PlayerInfo> players) { lock.writeLock().lock(); try { if (players == null) { return; } Iterator<PlayerInfo> iterator = players.iterator(); while (iterator.hasNext()) { Player player = iterator.next(); if (player.getId() == null) { iterator.remove(); } } if (playerGames.size() != players.size()) { throw new IllegalArgumentException("Diff players count"); } for (int index = 0; index < playerGames.size(); index ++) { updatePlayer(playerGames.get(index), players.get(index)); } } 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 shouldUpdateAll_loadFromSave() { Player player1 = createPlayer(VASYA); Player player2 = createPlayer(PETYA); List<PlayerInfo> infos = new LinkedList<PlayerInfo>(){{ add(new PlayerInfo(player1){{ setData("{\"some\":\"data1\"}"); }}); add(new PlayerInfo(player2){{ setData("{\"some\":\"data2\"}"); }}); }}; playerService.updateAll(infos); assertSaveLoaded(player1, "[{\"some\":\"data1\"}]"); assertSaveLoaded(player2, "[{\"some\":\"data2\"}]"); }
@Test public void shouldUpdateAll_loadFromSave_onlyIfSaveIsNotSame() { Player player1 = createPlayer(VASYA); Player player2 = createPlayer(PETYA); List<PlayerInfo> infos = new LinkedList<PlayerInfo>(){{ add(new PlayerInfo(player1){{ setData("{\"some\":\"data1\"}"); }}); add(new PlayerInfo(player2){{ setData("{}"); }}); }}; playerService.updateAll(infos); assertSaveLoaded(player1, "[{\"some\":\"data1\"}]"); assertSaveNotLoaded(player2); }
@Test public void shouldUpdateAll_loadFromSave_onlyIfSaveIsNotEmptyOrNull() { Player player1 = createPlayer(VASYA); Player player2 = createPlayer(PETYA); Player player3 = createPlayer(KATYA); Player player4 = createPlayer(OLIA); List<PlayerInfo> infos = new LinkedList<PlayerInfo>(){{ add(new PlayerInfo(player1){{ setData("{\"some\":\"data1\"}"); }}); add(new PlayerInfo(player2){{ setData(""); }}); add(new PlayerInfo(player3){{ setData(null); }}); add(new PlayerInfo(player4){{ setData("null"); }}); }}; playerService.updateAll(infos); assertSaveLoaded(player1, "[{\"some\":\"data1\"}]"); assertSaveNotLoaded(player2); assertSaveNotLoaded(player3); assertSaveNotLoaded(player4); }