use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class GroupCustActionTest 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 CreateSavingsAccountTest method testEnterAccountDetailsStep_DetailsEntered_NoQuestionGroup.
/**
* Account info entry step is complete. There is NO question group defined
* for "Create Savings" work flow.
*/
@Test
public void testEnterAccountDetailsStep_DetailsEntered_NoQuestionGroup() {
List<QuestionGroupDetail> groups = new ArrayList<QuestionGroupDetail>();
when(formBean.getQuestionGroups()).thenReturn(groups);
setCurrentState("enterAccountDetailsStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("detailsEntered");
resumeFlow(context);
assertCurrentStateEquals("previewStep");
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionGroupControllerTest method shouldGetAllQuestionGroups.
//TODO Question Groups added to testing data should have different titles, otherwise QuestionGroupSectionMatcher will throw exceptions. Matchers shouldn't throw exception when matching fail but return 'false'
@Test
public void shouldGetAllQuestionGroups() {
QuestionGroupDetail questionGroupDetail1 = getQuestionGroupDetail(1, TITLE + "1", "View", "Loan", true, true, "title1", "sectionName1");
QuestionGroupDetail questionGroupDetail2 = getQuestionGroupDetail(2, TITLE + "2", "View", "Loan", true, true, "title2", "sectionName2");
QuestionGroupDetail questionGroupDetail3 = getQuestionGroupDetail(3, TITLE + "3", "Create", "Loan", true, true, "title3", "sectionName3");
List<QuestionGroupDetail> questionGroupDetails = asList(questionGroupDetail1, questionGroupDetail2, questionGroupDetail3);
Map<String, List<QuestionGroupDetail>> questionGroupsCategoriesSplit = new HashMap<String, List<QuestionGroupDetail>>();
questionGroupsCategoriesSplit.put("View Loan", asList(questionGroupDetail1, questionGroupDetail2));
questionGroupsCategoriesSplit.put("Create Loan", asList(questionGroupDetail3));
when(questionnaireServiceFacade.getAllQuestionGroups()).thenReturn(questionGroupDetails);
when(questionnaireServiceFacade.getAllEventSources()).thenReturn(asList(questionGroupDetail2.getEventSources().get(0), questionGroupDetail3.getEventSources().get(0)));
String view = questionGroupController.getAllQuestionGroups(model, httpServletRequest);
assertThat(view, Is.is("viewQuestionGroups"));
verify(questionnaireServiceFacade).getAllQuestionGroups();
verify(questionnaireServiceFacade).getAllEventSources();
verify(model).addAttribute(Matchers.eq("questionGroups"), argThat(new QuestionGroupsGroupByEventSourceMatcher(questionGroupsCategoriesSplit)));
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionnaireMapperIntegrationTest method testMapEventSource.
private void testMapEventSource(String event, String source, String description) {
EventSourceDto eventSourceDto = new EventSourceDto(event, source, description);
List<SectionDetail> sectionDetails = getSectionDefinitions();
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(new QuestionGroupDetail(0, "Title", Arrays.asList(eventSourceDto), sectionDetails, false));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(not(nullValue())));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class SectionQuestionDaoIntegrationTest method shouldRetrieveSectionQuestionByQuestionIdSectionId.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionByQuestionIdSectionId() {
String title = "QG1" + currentTimeMillis();
SectionDetail sectionDetail1 = getSection("S1");
SectionDetail sectionDetail2 = getSection("S2");
List<SectionDetail> details = asList(sectionDetail1, sectionDetail2);
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
Integer questionId = questionGroup.getSections().get(1).getQuestions().get(1).getQuestion().getQuestionId();
Integer sectionId = questionGroup.getSections().get(1).getId();
List<SectionQuestion> sectionQuestions = sectionQuestionDao.retrieveFromQuestionIdSectionId(sectionId, questionId);
assertThat(sectionQuestions, is(notNullValue()));
assertThat(sectionQuestions.size(), is(1));
assertThat(sectionQuestions.get(0).getQuestionText(), is(sectionDetail2.getQuestionDetail(1).getText()));
}
Aggregations