Search in sources :

Example 6 with MandatoryAnswerNotFoundException

use of org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException in project head by mifos.

the class QuestionnaireServiceTest method testValidateResponse.

@Test
public void testValidateResponse() {
    List<QuestionDetail> questionDetails = asList(new QuestionDetail(12, "Question 1", QuestionType.FREETEXT, true, true));
    List<SectionDetail> sectionDetails = asList(getSectionDetailWithQuestions("Sec1", questionDetails, null, true));
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(1, "QG1", Arrays.asList(new EventSourceDto("Create", "Client", null)), sectionDetails, true);
    try {
        doThrow(new MandatoryAnswerNotFoundException("Title")).when(questionnaireValidator).validateForQuestionGroupResponses(asList(questionGroupDetail));
        questionnaireService.validateResponses(asList(questionGroupDetail));
        Assert.fail("Should not have thrown the validation exception");
    } catch (ValidationException e) {
        verify(questionnaireValidator, times(1)).validateForQuestionGroupResponses(asList(questionGroupDetail));
    }
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ValidationException(org.mifos.platform.validations.ValidationException) MandatoryAnswerNotFoundException(org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test)

Aggregations

MandatoryAnswerNotFoundException (org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException)6 ValidationException (org.mifos.platform.validations.ValidationException)6 Test (org.junit.Test)5 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)1 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)1 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)1 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)1 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)1 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 MessageResolver (org.springframework.binding.message.MessageResolver)1