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;
}
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));
}
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");
}
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;
}
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());
}
Aggregations