use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class LoanPrdActionTest method shouldSetSelectedQuestionGroupsOnSession.
@Test
public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", false));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(1)).thenReturn(questionGroupDetails.get(0));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(2)).thenReturn(questionGroupDetails.get(1));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(3)).thenReturn(questionGroupDetails.get(2));
when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
when(request.getSession()).thenReturn(session);
when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
Flow flow = new Flow();
when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(1, 2, 3));
loanPrdAction.setSelectedQuestionGroupsOnSession(request, loanOfferingBO, questionnaireServiceFacade);
List<QuestionGroupDetail> questionGroupDetailList = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
assertThat(questionGroupDetailList, is(notNullValue()));
assertThat(questionGroupDetailList.size(), is(2));
assertQuestionGroup(questionGroupDetailList.get(0), 1, "QG1");
assertQuestionGroup(questionGroupDetailList.get(1), 2, "QG2");
verify(questionnaireServiceFacade, times(3)).getQuestionGroupDetailForLoanPrd(anyInt());
verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
verify(request, times(1)).getSession();
verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class LoanPrdActionFormTest 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 QuestionnaireMapperTest method shouldMapQuestionGroupDefinitionToExistingQuestionGroup.
@Test
public void shouldMapQuestionGroupDefinitionToExistingQuestionGroup() {
when(eventSourceDao.retrieveByEventAndSource(anyString(), anyString())).thenReturn(new ArrayList<EventSourceEntity>());
when(questionDao.getDetails(12)).thenReturn(new QuestionEntity());
Section section = getSection("S1");
when(questionGroupDao.getDetails(123)).thenReturn(getQuestionGroup(123, "QG Title", section));
when(questionGroupDao.retrieveSectionByNameAndQuestionGroupId("S1", 123)).thenReturn(asList(section));
EventSourceDto eventSourceDto = getEventSource("Create", "Client");
List<SectionDetail> sectionDetails = asList(getSectionDefinition("S1", 12, TITLE), getSectionDefinition("S2", 0, TITLE));
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(123, TITLE, Arrays.asList(eventSourceDto), sectionDetails, true);
questionGroupDetail.setActive(false);
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
assertQuestionGroup(questionGroup, QuestionGroupState.INACTIVE);
assertThat(questionGroup.isEditable(), is(true));
verify(eventSourceDao, times(1)).retrieveByEventAndSource(anyString(), anyString());
verify(questionDao, times(1)).getDetails(12);
verify(questionGroupDao, times(1)).getDetails(123);
verify(questionGroupDao, times(1)).retrieveSectionByNameAndQuestionGroupId("S1", 123);
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupToQuestionGroupDetail.
@Test
public void shouldMapQuestionGroupToQuestionGroupDetail() {
QuestionGroup questionGroup = getQuestionGroup("Create", "Client", "S1", "S2");
QuestionGroupDetail questionGroupDetail = questionnaireMapper.mapToQuestionGroupDetail(questionGroup);
assertThat(questionGroupDetail, is(notNullValue()));
assertThat(questionGroupDetail.getTitle(), is(TITLE));
assertThat(questionGroupDetail.isEditable(), is(true));
assertThat(questionGroupDetail.isActive(), is(true));
List<SectionDetail> sectionDetails = questionGroupDetail.getSectionDetails();
assertThat(sectionDetails, is(notNullValue()));
assertThat(questionGroupDetail.getSectionDetails().size(), is(2));
assertThat(questionGroupDetail.getSectionDetails().get(0).getName(), is("S1"));
assertThat(questionGroupDetail.getSectionDetails().get(1).getName(), is("S2"));
EventSourceDto eventSourceDto = questionGroupDetail.getEventSources().get(0);
assertThat(eventSourceDto, is(notNullValue()));
assertThat(eventSourceDto.getEvent(), is("Create"));
assertThat(eventSourceDto.getSource(), is("Client"));
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupsToQuestionGroupDetails.
@Test
public void shouldMapQuestionGroupsToQuestionGroupDetails() {
int countOfQuestions = 10;
List<QuestionGroup> questionGroups = new ArrayList<QuestionGroup>();
for (int i = 0; i < countOfQuestions; i++) {
questionGroups.add(getQuestionGroup(1991, TITLE + i, "View", "Loan", QuestionGroupState.ACTIVE, true, getSection(SECTION + i), getSection(SECTION + (i + 1))));
}
List<QuestionGroupDetail> questionGroupDetails = questionnaireMapper.mapToQuestionGroupDetails(questionGroups);
assertThat(questionGroupDetails, is(notNullValue()));
for (int i = 0; i < countOfQuestions; i++) {
QuestionGroupDetail questionGroupDetail = questionGroupDetails.get(i);
assertThat(questionGroupDetail.getTitle(), is(TITLE + i));
SectionDetail sectionDefinition1 = questionGroupDetail.getSectionDetails().get(0);
assertThat(sectionDefinition1.getName(), is(SECTION + i));
List<SectionQuestionDetail> questionDetails1 = sectionDefinition1.getQuestions();
assertThat(questionDetails1.size(), is(1));
assertThat(questionDetails1.get(0).getText(), is(SECTION + i));
assertThat(questionDetails1.get(0).getQuestionType(), is(QuestionType.DATE));
SectionDetail sectionDefinition2 = questionGroupDetail.getSectionDetails().get(1);
assertThat(sectionDefinition2.getName(), is(SECTION + (i + 1)));
List<SectionQuestionDetail> questionDetails2 = sectionDefinition2.getQuestions();
assertThat(questionDetails2.size(), is(1));
assertThat(questionDetails2.get(0).getText(), is(SECTION + (i + 1)));
assertThat(questionDetails2.get(0).getQuestionType(), is(QuestionType.DATE));
}
}
Aggregations