use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class ClientCustActionTest method getSectionDetail.
private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
for (String answerChoice : answerChoices) {
choiceDtos.add(new ChoiceDto(answerChoice));
}
questionDetail.setAnswerChoices(choiceDtos);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireValidatorTest method getSection.
private SectionDetail getSection(String name) {
SectionDetail section = new SectionDetail();
section.setName(name);
section.addQuestion(new SectionQuestionDetail(new QuestionDetail(12, "Q1", QuestionType.INVALID, true, true), true, null));
return section;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldNotThrowExceptionWhenANumericQuestionWithNoBoundsHasAnswer.
@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
@Test
public void shouldNotThrowExceptionWhenANumericQuestionWithNoBoundsHasAnswer() {
QuestionDetail questionDetail = getNumericQuestionDetail("Numeric Question", null, null);
SectionDetail sectionWithOneQuestion = getSectionWithOneQuestion("Sec1", questionDetail, "121");
QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(0, "Title", "Create", "Client", asList(sectionWithOneQuestion));
try {
questionnaireValidator.validateForQuestionGroupResponses(asList(questionGroupDetail));
} catch (ValidationException e) {
fail("Should not have thrown the validation exception");
}
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireValidatorTest method getSectionWithOneQuestion.
private SectionDetail getSectionWithOneQuestion(String name, QuestionDetail questionDetail, String response) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true, response)));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldThrowExceptionWhenANumericQuestionHasAnswerLessThanMin.
@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
@Test
public void shouldThrowExceptionWhenANumericQuestionHasAnswerLessThanMin() {
QuestionDetail questionDetail = getNumericQuestionDetail("Numeric Question", 10, null);
SectionDetail sectionWithOneQuestion = getSectionWithOneQuestion("Sec1", questionDetail, "9");
QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(0, "Title", "Create", "Client", asList(sectionWithOneQuestion));
try {
questionnaireValidator.validateForQuestionGroupResponses(asList(questionGroupDetail));
fail("Should have thrown the validation exception");
} catch (ValidationException e) {
assertEquals(GENERIC_VALIDATION, e.getKey());
assertEquals(true, e.hasChildExceptions());
assertEquals(1, e.getChildExceptions().size());
ValidationException childException = e.getChildExceptions().get(0);
assertTrue(childException instanceof BadNumericResponseException);
assertEquals("Numeric Question", childException.getIdentifier());
assertEquals(Integer.valueOf(10), ((BadNumericResponseException) childException).getAllowedMinValue());
assertNull(((BadNumericResponseException) childException).getAllowedMaxValue());
}
}
Aggregations