Search in sources :

Example 1 with QuestionGroupsGroupByEventSourceMatcher

use of org.mifos.platform.questionnaire.matchers.QuestionGroupsGroupByEventSourceMatcher 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)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Test (org.junit.Test)1 QuestionGroupsGroupByEventSourceMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupsGroupByEventSourceMatcher)1 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)1