use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldThrowExceptionWhenQuestionTypeNotProvided.
@Test
public void shouldThrowExceptionWhenQuestionTypeNotProvided() {
try {
questionnaireValidator.validateForDefineQuestion(new QuestionDetail("Title 123", QuestionType.INVALID));
fail("Should have thrown the validation exception");
} catch (SystemException e) {
assertEquals(ANSWER_TYPE_NOT_PROVIDED, e.getKey());
}
}
use of org.mifos.platform.questionnaire.service.QuestionDetail 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.QuestionDetail 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.QuestionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldNotThrowExceptionForNumericQuestionType.
@Test
public void shouldNotThrowExceptionForNumericQuestionType() {
try {
QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
questionnaireValidator.validateForDefineQuestion(questionDetail);
} catch (SystemException e) {
fail("Should not have thrown the exception");
}
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldThrowExceptionForNumericQuestionTypeWhenInvalidBoundsGiven.
@Test
public void shouldThrowExceptionForNumericQuestionTypeWhenInvalidBoundsGiven() {
try {
QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
questionDetail.setNumericMin(100);
questionDetail.setNumericMax(10);
questionnaireValidator.validateForDefineQuestion(questionDetail);
fail("Should have thrown the exception");
} catch (SystemException e) {
assertEquals(INVALID_NUMERIC_BOUNDS, e.getKey());
}
}
Aggregations