}
}
public void testTrashQuestion() throws Throwable {
String result = null;
QuestionAction action = null;
try {
this.setUserOnSession("admin");
// test with no question ID
this.initAction("/do/jpsurvey/Survey", "trashQuestion");
result = this.executeAction();
assertNotNull(result);
assertEquals(Action.INPUT, result);
// test with no question ID
this.initAction("/do/jpsurvey/Survey", "trashQuestion");
this.addParameter("QuestionId", -1);
result = this.executeAction();
assertNotNull(result);
assertEquals(Action.SUCCESS, result);
action = (QuestionAction) this.getAction();
assertNotNull(action.getQuestions());
assertTrue(action.getQuestions().isEmpty());
// test with valid question ID
this.initAction("/do/jpsurvey/Survey", "trashQuestion");
this.addParameter("QuestionId", 1);
result = this.executeAction();
assertNotNull(result);
assertEquals(Action.SUCCESS, result);
action = (QuestionAction) this.getAction();
assertNotNull(action.getQuestion());
assertEquals(3, action.getQuestion().getChoices().size());
} catch (Throwable t) {
throw t;
}
}