Search in sources :

Example 31 with EventSourceDto

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

the class QuestionnaireServiceIntegrationTest method shouldGetQuestionGroupsByEventAndSource.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldGetQuestionGroupsByEventAndSource() throws SystemException {
    String title = "QG1" + currentTimeMillis();
    List<SectionDetail> details = asList(getSection("S1"), getSection("S2"));
    QuestionGroupDetail expectedQGDetail = defineQuestionGroup(title, "Create", "Client", details, false);
    List<QuestionGroupDetail> questionGroups = questionnaireService.getQuestionGroups(new EventSourceDto("Create", "Client", "Create.Client"));
    assertThat(questionGroups, is(notNullValue()));
    QuestionGroupDetail actualQGDetail = getMatchingQGDetailById(expectedQGDetail.getId(), questionGroups);
    assertThat(actualQGDetail, is(notNullValue()));
    assertThat(actualQGDetail.getTitle(), is(title));
}
Also used : EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with EventSourceDto

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

the class QuestionnaireServiceIntegrationTest method shouldRetrieveAllEventSources.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveAllEventSources() {
    List<EventSourceDto> eventSourceDtos = questionnaireService.getAllEventSources();
    assertNotNull(eventSourceDtos);
    assertThat(eventSourceDtos, new EventSourcesMatcher(asList(new EventSourceDto("Create", "Client", "Create Client"), new EventSourceDto("View", "Client", "View Client"), new EventSourceDto("Create", "Group", "Create Group"), new EventSourceDto("Approve", "Loan", "Approve Loan"), new EventSourceDto("Close", "Client", "Close Client"), new EventSourceDto("Create", "Loan", "Create Loan"), new EventSourceDto("View", "Loan", "View Loan"), new EventSourceDto("View", "Group", "View Group"), new EventSourceDto("Create", "Center", "Create Center"), new EventSourceDto("View", "Center", "View Center"), new EventSourceDto("Disburse", "Loan", "Disburse Loan"), new EventSourceDto("Create", "Savings", "Create Savings"), new EventSourceDto("View", "Savings", "View Savings"), new EventSourceDto("Create", "Office", "Create Office"), new EventSourceDto("Create", "Personnel", "Create Personnel"), new EventSourceDto("Close", "Loan", "Close Loan"), new EventSourceDto("Close", "Savings", "Close Savings"))));
}
Also used : EventSourcesMatcher(org.mifos.platform.questionnaire.matchers.EventSourcesMatcher) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 33 with EventSourceDto

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

the class QuestionnaireServiceIntegrationTest method shouldNotGetInQuestionGroupsWithAllInactiveQuestions.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldNotGetInQuestionGroupsWithAllInactiveQuestions() throws SystemException {
    String title = "QG1" + currentTimeMillis();
    List<SectionDetail> sectionDetails = asList(getSectionWithAllInactiveQuestions("S1"), getSectionWithAllInactiveQuestions("S2"));
    defineQuestionGroup(title, "Create", "Client", sectionDetails, true);
    List<QuestionGroupDetail> questionGroups = questionnaireService.getQuestionGroups(new EventSourceDto("Create", "Client", "Create.Client"));
    assertThat(questionGroups, is(notNullValue()));
    assertThat(questionGroups.size(), is(0));
}
Also used : EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 34 with EventSourceDto

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

the class QuestionnaireServiceIntegrationTest method shouldNotGetInActiveQuestionGroupsByEventAndSource.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldNotGetInActiveQuestionGroupsByEventAndSource() throws SystemException {
    String title = "QG1" + currentTimeMillis();
    List<SectionDetail> details = asList(getSection("S1"), getSection("S2"));
    QuestionGroupDetail expectedQGDetail = defineQuestionGroup(title, "Create", "Client", details, true);
    setState(expectedQGDetail.getId(), QuestionGroupState.INACTIVE);
    List<QuestionGroupDetail> questionGroups = questionnaireService.getQuestionGroups(new EventSourceDto("Create", "Client", "Create.Client"));
    assertThat(questionGroups, is(notNullValue()));
    QuestionGroupDetail actualQGDetail = getMatchingQGDetailById(expectedQGDetail.getId(), questionGroups);
    assertThat(actualQGDetail, is(Matchers.nullValue()));
}
Also used : EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with EventSourceDto

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

the class QuestionnaireValidatorImpl method validateForDefineQuestionGroup.

@Override
public void validateForDefineQuestionGroup(QuestionGroupDetail questionGroupDetail) throws SystemException {
    validateQuestionGroupTitle(questionGroupDetail);
    validateQuestionGroupSections(questionGroupDetail.getSectionDetails());
    List<EventSourceDto> eventSourceDtos = questionGroupDetail.getEventSources();
    if (eventSourceDtos == null || eventSourceDtos.size() == 0) {
        throw new SystemException(INVALID_EVENT_SOURCE);
    } else {
        for (EventSourceDto eventSourceDto : eventSourceDtos) {
            validateForEventSource(eventSourceDto);
        }
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Aggregations

EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)39 Test (org.junit.Test)28 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)15 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)12 ArrayList (java.util.ArrayList)10 Transactional (org.springframework.transaction.annotation.Transactional)7 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)6 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)5 SystemException (org.mifos.framework.exceptions.SystemException)4 EventSourcesMatcher (org.mifos.platform.questionnaire.matchers.EventSourcesMatcher)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)3 ValidationException (org.mifos.platform.validations.ValidationException)3 LinkedHashMap (java.util.LinkedHashMap)2 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)2 Section (org.mifos.platform.questionnaire.domain.Section)2 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)2 MandatoryAnswerNotFoundException (org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException)2 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2