executeWithToken(comm, false);
comm = new SaveSchoolRankCommand(yale, getUser(), 2);
executeWithToken(comm, false);
User savedUser = getUser();
assertEquals(3, savedUser.getSchoolRankings().size());
Application harvardApplication = savedUser.getSchoolRankings()
.get(1);
assertEquals(harvard, harvardApplication.getSchool());
assertEquals(1, harvardApplication.getSortOrder());
// save pro/con and notes to the application
harvardApplication.setNotes(TEXT);
harvardApplication.getPros().add(A);
harvardApplication.getPros().add(B);
harvardApplication.getCons().add(C);
SaveApplicationCommand command = new SaveApplicationCommand(
harvardApplication);
executeWithToken(command, false);
User savedUser2 = getUser();
Application savedHarvard = savedUser2.getSchoolRankings().get(1);
assertEquals(1, savedHarvard.getSortOrder());
assertEquals(harvard, savedHarvard.getSchool());
assertEquals(TEXT, savedHarvard.getNotes());
assertEquals(A, savedHarvard.getPros().get(0));
assertEquals(B, savedHarvard.getPros().get(1));
assertEquals(C, savedHarvard.getCons().get(0));
// edit the original application and save again
harvardApplication.getPros().clear();
harvardApplication.getCons().add(B);
harvardApplication.setNotes(C);
SaveApplicationCommand command2 = new SaveApplicationCommand(
harvardApplication);
executeWithToken(command2, false);
User savedUser3 = getUser();
Application savedHarvard2 = savedUser3.getSchoolRankings().get(1);
assertEquals(1, savedHarvard2.getSortOrder());
assertEquals(harvard, savedHarvard2.getSchool());
assertEquals(C, savedHarvard2.getNotes());