### Question:
PlayerGames implements Iterable<PlayerGame>, Tickable { public int size() { return all.size(); } PlayerGames(); void onAdd(Consumer<PlayerGame> consumer); void onRemove(Consumer<PlayerGame> consumer); void init(ReadWriteLock lock); void removeCurrent(Player player); void remove(Player player); PlayerGame get(String id); PlayerGame get(GamePlayer player); PlayerGame add(Player player, String roomName, PlayerSave save); boolean isEmpty(); @Override Iterator<PlayerGame> iterator(); List<Player> players(); int size(); void clear(); List<PlayerGame> getAll(Predicate<PlayerGame> predicate); static Predicate<PlayerGame> withType(String gameType); static Predicate<PlayerGame> withAll(); static Predicate<PlayerGame> withRoom(String room); Predicate<PlayerGame> withActive(); List<GameType> getGameTypes(); @Override void tick(); void reloadCurrent(PlayerGame playerGame); void reload(Game game, String roomName, JSONObject save); void reloadAll(boolean shuffle); void reloadAll(boolean shuffle, Predicate<PlayerGame> predicate); List<Player> getPlayers(String gameName); void changeLevel(String playerId, int level); void setLevel(String playerId, JSONObject save); void changeRoom(String playerId, String roomName); PlayerGame get(int index); List<PlayerGame> all(); List<PlayerGame> active(); Stream<PlayerGame> stream(); Multimap<String, Room> rooms(); List<String> getRooms(boolean isAll); static final boolean ALL; static final boolean ACTIVE; }### Answer:
@Test public void testLoadLevelProgressFromSave_checkProgress() { MultiplayerType type = MultiplayerType.TRAINING.apply(3); Player player1 = createPlayer("player1", type, new PlayerSave("{'levelProgress':{'total':3,'current':1,'lastPassed':0}}")); Player player2 = createPlayer("player2", type, new PlayerSave("{'levelProgress':{'total':3,'current':2,'lastPassed':1}}")); Player player3 = createPlayer("player3", type, new PlayerSave("{'levelProgress':{'total':3,'current':3,'lastPassed':2}}")); assertEquals(3, fields.size()); assertProgress("player1", "{'current':1,'passed':0,'total':3,'valid':true}"); assertProgress("player2", "{'current':2,'passed':1,'total':3,'valid':true}"); assertProgress("player3", "{'current':3,'passed':2,'total':3,'valid':true}"); }
@Test public void testLoadLevelProgressFromSave_allInMultiple() { MultiplayerType type = MultiplayerType.TRAINING.apply(3); Player player1 = createPlayer("player1", type, new PlayerSave("{'levelProgress':{'total':3,'current':3,'lastPassed':2}}")); Player player2 = createPlayer("player2", type, new PlayerSave("{'levelProgress':{'total':3,'current':3,'lastPassed':2}}")); Player player3 = createPlayer("player3", type, new PlayerSave("{'levelProgress':{'total':3,'current':3,'lastPassed':2}}")); assertEquals(1, fields.size()); }