@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)));
}