use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupController method getQuestionGroup.
@RequestMapping("/viewQuestionGroupDetail.ftl")
public String getQuestionGroup(ModelMap model, HttpServletRequest httpServletRequest) {
String questionGroupId = httpServletRequest.getParameter("questionGroupId");
try {
if (isInvalidNumber(questionGroupId)) {
model.addAttribute("error_message_code", QuestionnaireConstants.INVALID_QUESTION_GROUP_ID);
} else {
QuestionGroupDetail questionGroupDetail = questionnaireServiceFacade.getQuestionGroupDetail(Integer.valueOf(questionGroupId));
QuestionGroupForm questionGroupForm = new QuestionGroupForm(questionGroupDetail);
model.addAttribute("questionGroupDetail", questionGroupForm);
model.addAttribute("eventSources", getAllQgEventSources());
}
} catch (SystemException e) {
//TODO: move mifosLogManager to common after dependency resolution
//MifosLogManager.getLogger(LoggerConstants.ROOTLOGGER).error(e.getMessage(), e);
model.addAttribute("error_message_code", QuestionnaireConstants.QUESTION_GROUP_NOT_FOUND);
}
return "viewQuestionGroupDetail";
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method getQuestionGroupForm.
private QuestionGroupForm getQuestionGroupForm(String title, String eventSourceId, String... sectionNames) {
QuestionGroupForm questionGroup = new QuestionGroupForm();
questionGroup.setTitle(title);
questionGroup.setEventSourceIds(Arrays.asList(eventSourceId));
for (String sectionName : sectionNames) {
questionGroup.setSectionName(sectionName);
questionGroup.addCurrentSection();
}
return questionGroup;
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddQuestionForEmptyType.
@Test
public void testAddQuestionForEmptyType() {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client", "Default");
questionGroupForm.setValidator(validator);
questionGroupForm.getCurrentQuestion().setText(TITLE);
questionGroupForm.getCurrentQuestion().setType(null);
when(messageContext.hasErrorMessages()).thenReturn(true);
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.addQuestion(questionGroupForm, requestContext);
assertThat(result, is("failure"));
verify(requestContext, times(1)).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("NotNull.QuestionGroupForm.currentQuestion.type")));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddSectionWithoutQuestions.
@Test
public void testAddSectionWithoutQuestions() throws Exception {
when(requestContext.getMessageContext()).thenReturn(messageContext);
QuestionGroupForm questionGroup = new QuestionGroupForm();
questionGroup.setTitle("title");
questionGroup.setSectionName("sectionName");
String result = questionGroupController.addSection(questionGroup, requestContext);
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.no.question.in.section")));
assertThat(result, Is.is("failure"));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddQuestionForInvalidNumericBounds.
@Test
public void testAddQuestionForInvalidNumericBounds() {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client", "Default");
questionGroupForm.setValidator(validator);
questionGroupForm.getCurrentQuestion().setText(TITLE);
questionGroupForm.getCurrentQuestion().setType("number");
questionGroupForm.getCurrentQuestion().setNumericMin(100);
questionGroupForm.getCurrentQuestion().setNumericMax(10);
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.addQuestion(questionGroupForm, requestContext);
assertThat(result, is("failure"));
verify(requestContext, times(1)).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(QuestionnaireConstants.INVALID_NUMERIC_BOUNDS)));
}
Aggregations