Search in sources :

Example 1 with UploadQuestionGroupForm

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)));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) ValidationException(org.mifos.platform.validations.ValidationException) UploadQuestionGroupForm(org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm) Test(org.junit.Test)

Example 2 with UploadQuestionGroupForm

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)));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) UploadQuestionGroupForm(org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm) SystemException(org.mifos.framework.exceptions.SystemException) Test(org.junit.Test)

Example 3 with UploadQuestionGroupForm

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");
}
Also used : UploadQuestionGroupForm(org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm) Test(org.junit.Test)

Example 4 with UploadQuestionGroupForm

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")));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) UploadQuestionGroupForm(org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm) Test(org.junit.Test)

Example 5 with UploadQuestionGroupForm

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)));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) UploadQuestionGroupForm(org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 UploadQuestionGroupForm (org.mifos.platform.questionnaire.ui.model.UploadQuestionGroupForm)5 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)4 SystemException (org.mifos.framework.exceptions.SystemException)1 ValidationException (org.mifos.platform.validations.ValidationException)1