}
}
//TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
public void testMoveChoiceDown() throws Throwable {
Survey survey = this.createFakeSurveyForTest(true, true, false);
Survey test = null;
String result = null;
try {
this.setUserOnSession("admin");
// save the survey
this.getSurveyManager().saveSurvey(survey);
// update internal id's by reloading the object
survey = this.getSurveyManager().loadSurvey(survey.getId());
// invoke without parameters
this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.INPUT, result);
// invoke with invalid id
this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
this.addParameter("choiceId", -1);
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
// move down the last has no effects
test = this.getSurveyManager().loadSurvey(survey.getId());
this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(1).getId());
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
survey = this.getSurveyManager().loadSurvey(survey.getId());
assertNotNull(survey);
assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(1).getId());
// normal operations
test=getSurveyManager().loadSurvey(survey.getId());
this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(0).getId());
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
survey = this.getSurveyManager().loadSurvey(survey.getId());
assertNotNull(survey);
assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(0).getId());
} catch (Throwable t) {
throw t;
} finally {
getSurveyManager().deleteSurvey(survey.getId());
}