use of org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm in project head by mifos.
the class UploadQuestionGroupControllerTest method testUploadQuestionGroup_UploadFailureDuringValidation.
@Test
public void testUploadQuestionGroup_UploadFailureDuringValidation() {
when(requestContext.getMessageContext()).thenReturn(messageContext);
ValidationException validationException = new ValidationException(GENERIC_VALIDATION);
validationException.addChildException(new ValidationException(QUESTION_GROUP_TITLE_NOT_PROVIDED));
validationException.addChildException(new ValidationException(DUPLICATE_QUESTION_FOUND_IN_SECTION));
doThrow(validationException).when(questionnaireServiceFacade).uploadPPIQuestionGroup("INDIA");
UploadQuestionGroupForm form = new UploadQuestionGroupForm();
form.setSelectedCountry("INDIA");
String result = controller.upload(form, requestContext);
assertThat(result, is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(QUESTION_GROUP_TITLE_NOT_PROVIDED)));
verify(messageContext).addMessage(argThat(new MessageMatcher(DUPLICATE_QUESTION_FOUND_IN_SECTION)));
}
use of org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm in project head by mifos.
the class UploadQuestionGroupControllerTest method testUploadQuestionGroup_UploadFailureDuringPPIProcessing.
@Test
public void testUploadQuestionGroup_UploadFailureDuringPPIProcessing() {
when(requestContext.getMessageContext()).thenReturn(messageContext);
doThrow(new SystemException(FETCH_PPI_COUNTRY_XML_FAILED)).when(questionnaireServiceFacade).uploadPPIQuestionGroup("INDIA");
UploadQuestionGroupForm form = new UploadQuestionGroupForm();
form.setSelectedCountry("INDIA");
String result = controller.upload(form, requestContext);
assertThat(result, is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(FETCH_PPI_COUNTRY_XML_FAILED)));
}
use of org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm in project head by mifos.
the class UploadQuestionGroupControllerTest method testUploadQuestionGroup.
@Test
public void testUploadQuestionGroup() {
UploadQuestionGroupForm form = new UploadQuestionGroupForm();
form.setSelectedCountry("INDIA");
String result = controller.upload(form, requestContext);
assertThat(result, is("success"));
verify(questionnaireServiceFacade).uploadPPIQuestionGroup("INDIA");
}
use of org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm in project head by mifos.
the class UploadQuestionGroupControllerTest method testUploadQuestionGroup_ValidateForInvalidCountry.
@Test
public void testUploadQuestionGroup_ValidateForInvalidCountry() {
when(requestContext.getMessageContext()).thenReturn(messageContext);
UploadQuestionGroupForm form = new UploadQuestionGroupForm();
form.setSelectedCountry(QuestionnaireConstants.SELECT_ONE);
String result = controller.upload(form, requestContext);
assertThat(result, is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.ppi.country")));
}
use of org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm in project head by mifos.
the class UploadQuestionGroupControllerTest method testUploadQuestionGroup_UploadFailureDueToGenericError.
@Test
public void testUploadQuestionGroup_UploadFailureDueToGenericError() {
when(requestContext.getMessageContext()).thenReturn(messageContext);
String exceptionCode = "Random Exception";
doThrow(new RuntimeException(exceptionCode)).when(questionnaireServiceFacade).uploadPPIQuestionGroup("INDIA");
UploadQuestionGroupForm form = new UploadQuestionGroupForm();
form.setSelectedCountry("INDIA");
String result = controller.upload(form, requestContext);
assertThat(result, is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher(exceptionCode)));
}
Aggregations