}
}
public void testFreeTextList() throws Throwable {
String result = null;
ChoiceAction action = null;
try {
this.setUserOnSession("admin");
// invoke without parameters
this.initAction("/do/jpsurvey/Survey", "freeTextList");
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.INPUT, result);
// invoke with invalid choice ID
this.initAction("/do/jpsurvey/Survey", "freeTextList");
this.addParameter("choiceId", -1);
this.addParameter("questionId", 2);
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
action = (ChoiceAction) this.getAction();
assertNotNull(action.getFreeTextMap());
assertTrue(action.getFreeTextMap().isEmpty());
// invoke with NON free text choice ID
this.initAction("/do/jpsurvey/Survey", "freeTextList");
this.addParameter("choiceId", 2);
this.addParameter("questionId", 2);
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
action = (ChoiceAction) this.getAction();
assertNotNull(action.getFreeTextMap());
assertTrue(action.getFreeTextMap().isEmpty());
this.initAction("/do/jpsurvey/Survey", "freeTextList");
this.addParameter("choiceId", 6);
this.addParameter("questionId", 2);
result = this.executeAction();
assertNotNull(result);
assertEquals(BaseAction.SUCCESS, result);
action = (ChoiceAction) this.getAction();
assertNotNull(action.getFreeTextMap());
assertFalse(action.getFreeTextMap().isEmpty());
assertEquals(1, action.getFreeTextMap().size());
assertEquals(Integer.valueOf(1), action.getFreeTextMap().get("lorem ipsum dolor"));
} catch (Throwable t) {
throw t;
}
}