Search in sources :

Example 21 with QuestionGroupDetail

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;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail)

Example 22 with 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");
}
Also used : MockExternalContext(org.springframework.webflow.test.MockExternalContext) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with QuestionGroupDetail

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)));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) HashMap(java.util.HashMap) QuestionGroupsGroupByEventSourceMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupsGroupByEventSourceMatcher) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 24 with QuestionGroupDetail

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));
}
Also used : EventSourceEntity(org.mifos.platform.questionnaire.domain.EventSourceEntity) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 25 with QuestionGroupDetail

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()));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

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