Search in sources :

Example 56 with QuestionGroupDetail

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

the class QuestionGroupFormTest method shouldGetSections.

@Test
public void shouldGetSections() {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName("Section1");
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(123, "Title", null, asList(sectionDetail), false);
    QuestionGroupForm questionGroupForm = new QuestionGroupForm(questionGroupDetail);
    List<SectionDetailForm> sections = questionGroupForm.getSections();
    assertThat(questionGroupForm.getInitialCountOfSections(), is(1));
    assertThat(sections, notNullValue());
    assertThat(sections.size(), is(1));
    assertThat(sections.get(0).getName(), is("Section1"));
    assertThat(sections.get(0).getInitialCountOfQuestions(), is(0));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test)

Example 57 with QuestionGroupDetail

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

the class QuestionGroupControllerTest method testCreateQuestionGroupSuccess.

@Test
public void testCreateQuestionGroupSuccess() throws Exception {
    QuestionGroupForm questionGroup = getQuestionGroupForm("   " + TITLE + " ", "Create.Client", "S1", "S2");
    String result = questionGroupController.defineQuestionGroup(questionGroup, requestContext, true);
    assertThat(result, Is.is("success"));
    QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(TITLE, "Create", "Client", "S1", "S2");
    questionGroupDetail.setActive(true);
    verify(questionnaireServiceFacade).createActiveQuestionGroup(argThat(new QuestionGroupDetailMatcher(questionGroupDetail)));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetailMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 58 with QuestionGroupDetail

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

the class QuestionGroupControllerTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(int questionGroupId, String title, String... sectionNames) {
    List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
    for (String sectionName : sectionNames) {
        SectionDetail sectionDetail = new SectionDetail();
        sectionDetail.setName(sectionName);
        sectionDetails.add(sectionDetail);
    }
    return new QuestionGroupDetail(questionGroupId, title, sectionDetails);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail)

Example 59 with QuestionGroupDetail

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

the class CreateSavingsAccountFormBeanTest method validateAnswerQuestionGroupStepEmptyQuestionGroupShouldPass.

@Test
public void validateAnswerQuestionGroupStepEmptyQuestionGroupShouldPass() {
    List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
    formBean.setQuestionGroups(questionGroups);
    formBean.validateAnswerQuestionGroupStep(validationContext);
    MessageContext messageContext = validationContext.getMessageContext();
    Message[] messages = messageContext.getAllMessages();
    Assert.assertEquals(0, messages.length);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) Message(org.springframework.binding.message.Message) ArrayList(java.util.ArrayList) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Example 60 with QuestionGroupDetail

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

the class LoanPrdActionTest method getQuestionGroupDetail.

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

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