use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class ValidationExceptionMessageExtractorTest method testMandatoryAnswerNotFoundException.
@Test
public void testMandatoryAnswerNotFoundException() {
MandatoryAnswerNotFoundException e = new MandatoryAnswerNotFoundException("Title");
ValidationException parent = new ValidationException("Key");
parent.addChildException(e);
ValidationExceptionMessageExtractor extractor = new ValidationExceptionMessageExtractor();
extractor.extract(context, parent);
verify(context).addMessage(any(MessageResolver.class));
}
use of org.mifos.platform.validations.ValidationException 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));
}
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method questionsHaveInvalidOrders.
private boolean questionsHaveInvalidOrders(List<QuestionDto> questions, ValidationException parentException) {
boolean invalid = false;
if (!allQuestionsHaveOrders(questions)) {
parentException.addChildException(new ValidationException(QUESTION_ORDER_NOT_PROVIDED));
invalid = true;
} else if (!allQuestionsHaveUniqueOrders(questions)) {
parentException.addChildException(new ValidationException(QUESTION_ORDER_DUPLICATE));
invalid = true;
}
return invalid;
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method questionsHaveInvalidNames.
private boolean questionsHaveInvalidNames(List<QuestionDto> questions, ValidationException parentException, boolean withDuplicateQuestionTextCheck) {
boolean invalid = false;
if (!allQuestionsHaveNames(questions)) {
parentException.addChildException(new ValidationException(QUESTION_TEXT_NOT_PROVIDED));
invalid = true;
} else if (withDuplicateQuestionTextCheck && !allQuestionsHaveUniqueNames(questions)) {
parentException.addChildException(new ValidationException(QUESTION_TITLE_DUPLICATE));
invalid = true;
}
return invalid;
}
use of org.mifos.platform.validations.ValidationException in project head by mifos.
the class QuestionnaireValidatorImpl method validateForDefineQuestion.
@Override
public void validateForDefineQuestion(QuestionDto questionDto) {
ValidationException parentException = new ValidationException(GENERIC_VALIDATION);
validateQuestion(questionDto, parentException, false, true);
if (parentException.hasChildExceptions()) {
throw parentException;
}
}
Aggregations