use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class CreateSavingsAccountTest method testAnswerQuestionGroupStep_QuestionsAnswered.
@Test
public void testAnswerQuestionGroupStep_QuestionsAnswered() {
List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
doNothing().when(questionnaireServiceFacade).validateResponses(questionGroups);
setCurrentState("answerQuestionGroupStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("questionsAnswered");
resumeFlow(context);
assertCurrentStateEquals("previewStep");
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail 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.QuestionGroupDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldThrowExceptionWhenAMandatoryQuestionHasNoAnswer.
@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
@Test
public void shouldThrowExceptionWhenAMandatoryQuestionHasNoAnswer() {
QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(0, "Title", "Create", "Client");
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 MandatoryAnswerNotFoundException);
assertEquals("Q1", childException.getIdentifier());
}
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail 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());
}
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionGroupFormTest method shouldGetEventSourceId.
@Test
public void shouldGetEventSourceId() {
EventSourceDto eventSourceDto = new EventSourceDto("Create", "Client", "Create Client");
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(123, "Title", Arrays.asList(eventSourceDto), new ArrayList<SectionDetail>(), false);
QuestionGroupForm questionGroupForm = new QuestionGroupForm(questionGroupDetail);
assertThat(questionGroupForm.getEventSourceIds().get(0), is("Create.Client"));
}
Aggregations