### Question:
LevelProgress { @Override public String toString() { return JsonUtils.toStringSorted(this).replace('"', '\''); } LevelProgress();  LevelProgress(MultiplayerType type);  LevelProgress(JSONObject json); static LevelProgress parse(String jsonString); JSONObject saveTo(JSONObject json); void change(int level, int passed); void change(int level); static JSONObject winLevel(JSONObject json); boolean isValid(); boolean canChange(int level); @Override String toString();  }### Answer:
@Test public void constructFromInts_valid() { int total = 5; int current = 2; int passed = 1; LevelProgress progress = new LevelProgress(total, current, passed); assertEquals("{'current':2,'passed':1,'total':5,'valid':true}", progress.toString()); }
@Test public void constructFromInts_invalid_totalLessThanCurrent() { int total = 2; int current = 5; int passed = 1; LevelProgress progress = new LevelProgress(total, current, passed); assertEquals("{'current':5,'passed':1,'total':2,'valid':false}", progress.toString()); }
@Test public void constructFromInts_invalid_currentMoreThanPassedPlus1() { int total = 5; int current = 2; int passed = 0; LevelProgress progress = new LevelProgress(total, current, passed); assertEquals("{'current':2,'passed':0,'total':5,'valid':false}", progress.toString()); }
@Test public void constructFromInts_invalid_passedMoreThanTotal() { int total = 5; int current = 2; int passed = 6; LevelProgress progress = new LevelProgress(total, current, passed); assertEquals("{'current':2,'passed':6,'total':5,'valid':false}", progress.toString()); }
@Test public void constructFromInts_valid_totalCanBeEqualsWithCurrent_thisIsLasMultipleLevelForTraining() { int total = 2; int current = total; int passed = 1; LevelProgress progress = new LevelProgress(total, current, passed); assertEquals("{'current':2,'passed':1,'total':2,'valid':true}", progress.toString()); }
@Test public void constructFromType_anyOtherType() { MultiplayerType type = MultiplayerType.SINGLE; LevelProgress progress = new LevelProgress(type); assertEquals("{'current':0,'passed':-1,'total':1,'valid':true}", progress.toString()); }
@Test public void constructFromType_trainingType() { MultiplayerType type = MultiplayerType.TRAINING.apply(5); LevelProgress progress = new LevelProgress(type); assertEquals("{'current':0,'passed':-1,'total':5,'valid':true}", progress.toString()); }
@Test public void constructFromJSON_validType() { JSONObject json = new JSONObject("{'levelProgress':{'total':3,'current':1,'lastPassed':0}}"); LevelProgress progress = new LevelProgress(json); assertEquals("{'current':1,'passed':0,'total':3,'valid':true}", progress.toString()); }