### Question:
MultiplayerType { public int loadProgress(Game game, JSONObject save) { int roomSize; if (isTraining() && save.has("levelProgress")) { LevelProgress progress = new LevelProgress(save); roomSize = this.getRoomSize(progress); game.setProgress(progress); } else { roomSize = this.getRoomSize(); game.setProgress(new LevelProgress(this)); } return roomSize; } MultiplayerType(int roomSize, boolean disposable);  MultiplayerType(int roomSize, int levelsCount, boolean disposable); boolean isDisposable(); boolean isSingle(); boolean isMultiple(); boolean isTriple(); boolean isTournament(); boolean isQuadro(); boolean isTeam(); boolean isSingleplayer(); boolean isMultiplayer(); boolean isTraining(); boolean isLastLevel(int levelNumber); String getType(); int loadProgress(Game game, JSONObject save); int getRoomSize(Object data); int getRoomSize(); int getLevelsCount(); final static boolean DISPOSABLE; static final MultiplayerType SINGLE; static final MultiplayerType MULTIPLE; static final BiFunction<Integer, Boolean, MultiplayerType> TEAM; static final MultiplayerType TOURNAMENT; static final MultiplayerType TRIPLE; static MultiplayerType QUADRO; static final Function<Integer, MultiplayerType> TRAINING; }### Answer:
@Test public void loadProgress_forAnyType() { MultiplayerType type = MultiplayerType.SINGLE; Game game = new StubGame(); JSONObject save = new JSONObject("{'any':'data'}"); int roomSize = type.loadProgress(game, save); assertEquals(1, roomSize); assertEquals("{'current':0,'passed':-1,'total':1,'valid':true}", game.getProgress().toString()); }
@Test public void loadProgress_forTrainingType_atFirstSingleLevel() { MultiplayerType type = MultiplayerType.TRAINING.apply(3); Game game = new StubGame(); JSONObject save = new JSONObject("{'levelProgress':{'total':3,'current':1,'lastPassed':0}}"); int roomSize = type.loadProgress(game, save); assertEquals(1, roomSize); assertEquals("{'current':1,'passed':0,'total':3,'valid':true}", game.getProgress().toString()); }
@Test public void loadProgress_forTrainingType_atLastMultipleLevel() { MultiplayerType type = MultiplayerType.TRAINING.apply(3); Game game = new StubGame(); JSONObject save = new JSONObject("{'levelProgress':{'total':3,'current':3,'lastPassed':2}}"); int roomSize = type.loadProgress(game, save); assertEquals(Integer.MAX_VALUE, roomSize); assertEquals("{'current':3,'passed':2,'total':3,'valid':true}", game.getProgress().toString()); }