Search in sources :

Example 11 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class QuestionGroupFilterForLoanTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(int id, String title) {
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail();
    questionGroupDetail.setId(id);
    questionGroupDetail.setTitle(title);
    return questionGroupDetail;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail)

Example 12 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoLoanOfferingQuestionGroups.

@Test
public void shouldDoFilterForNoLoanOfferingQuestionGroups() {
    QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
    LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
    loanOfferingBO.setQuestionGroups(new HashSet<QuestionGroupReference>());
    questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
    List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
    assertThat(filteredQuestionGroupDetails, is(notNullValue()));
    assertThat(filteredQuestionGroupDetails.size(), is(0));
    loanOfferingBO.setQuestionGroups(null);
    filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
    assertThat(filteredQuestionGroupDetails, is(notNullValue()));
    assertThat(filteredQuestionGroupDetails.size(), is(0));
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Test(org.junit.Test)

Example 13 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class QuestionnaireFlowAdapterTest method testShouldFetchQuestions.

@Test
public void testShouldFetchQuestions() {
    QuestionnaireFlowAdapter createLoanQuestionnaire = new QuestionnaireFlowAdapter("Create", "Loan", ActionForwards.schedulePreview_success, "clientsAndAccounts.ftl", serviceLocator);
    List<QuestionGroupDetail> applicableGroups = getQuestionGroups();
    when(mapping.findForward("captureQuestionResponses")).thenReturn(captureResponseActFwd);
    when(mapping.findForward("schedulePreview_success")).thenReturn(schedulePreview_successFwd);
    when(serviceLocator.getService(request)).thenReturn(questionnaireServiceFacade);
    when(request.getRequestURI()).thenReturn("/mifos/loanAccountAction.do");
    when(request.getContextPath()).thenReturn("/mifos");
    when(questionnaireServiceFacade.getQuestionGroups("Create", "Loan")).thenReturn(applicableGroups);
    ActionForward fwdTo = createLoanQuestionnaire.fetchAppliedQuestions(mapping, questionForm, request, ActionForwards.schedulePreview_success);
    Assert.assertEquals(captureResponseActFwd, fwdTo);
    //Assert.assertEquals(applicableGroups, questionForm.getQuestionGroups());
    verify(questionForm).setQuestionGroups(applicableGroups);
    verify(request).setAttribute("questionsHostForm", questionForm);
    verify(request).setAttribute("origFlowRequestURI", "/loanAccountAction.do");
    verify(request).setAttribute("cancelToURL", "clientsAndAccounts.ftl");
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ActionForward(org.apache.struts.action.ActionForward) Test(org.junit.Test)

Example 14 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class ClientCustActionTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(String title, List<String> answerChoices) {
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail();
    questionGroupDetail.setTitle(title);
    questionGroupDetail.setId(123);
    questionGroupDetail.setSectionDetails(asList(getSectionDetail("Section1", "Question1", answerChoices)));
    return questionGroupDetail;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail)

Example 15 with QuestionGroupDetail

use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.

the class QuestionnaireServiceTest method shouldSaveResponses.

@Test
public void shouldSaveResponses() {
    List<QuestionDetail> questionDetails = asList(new QuestionDetail(12, "Question 1", QuestionType.FREETEXT, true, true));
    List<SectionDetail> sectionDetails = asList(getSectionDetailWithQuestions("Sec1", questionDetails, "value", false));
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(1, "QG1", Arrays.asList(new EventSourceDto("Create", "Client", null)), sectionDetails, true);
    QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
    questionGroupInstance.setVersionNum(0);
    when(questionGroupInstanceDao.retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(1, 1)).thenReturn(asList(questionGroupInstance));
    questionnaireService.saveResponses(new QuestionGroupDetails(1, 1, 1, asList(questionGroupDetail)));
    verify(questionGroupInstanceDao).retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(1, 1);
    verify(questionnaireValidator, times(1)).validateForQuestionGroupResponses(asList(questionGroupDetail));
    // TODO: Verify the contents using a custom matcher
    verify(questionGroupInstanceDao, times(1)).saveOrUpdateAll(Matchers.<List<QuestionGroupInstance>>any());
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetails(org.mifos.platform.questionnaire.service.QuestionGroupDetails) 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

QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)74 Test (org.junit.Test)43 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)25 ArrayList (java.util.ArrayList)23 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)15 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)11 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)11 List (java.util.List)8 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)8 ValidationException (org.mifos.platform.validations.ValidationException)7 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)6 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)6 SystemException (org.mifos.framework.exceptions.SystemException)5 Arrays.asList (java.util.Arrays.asList)4 QuestionGroupReference (org.mifos.accounts.productdefinition.business.QuestionGroupReference)4 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)4 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)4 Transactional (org.springframework.transaction.annotation.Transactional)4 HashMap (java.util.HashMap)3