@Test
 public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
   List<QuestionGroupDetail> questionGroupDetails =
       asList(
           getQuestionGroupDetail(1, "QG1", true),
           getQuestionGroupDetail(2, "QG2", true),
           getQuestionGroupDetail(3, "QG3", false));
   when(questionnaireServiceFacade.getQuestionGroupDetail(1))
       .thenReturn(questionGroupDetails.get(0));
   when(questionnaireServiceFacade.getQuestionGroupDetail(2))
       .thenReturn(questionGroupDetails.get(1));
   when(questionnaireServiceFacade.getQuestionGroupDetail(3))
       .thenReturn(questionGroupDetails.get(2));
   when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
   when(request.getSession()).thenReturn(session);
   when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
   Flow flow = new Flow();
   when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
   LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
   loanOfferingBO.setQuestionGroups(getQustionGroups(1, 2, 3));
   loanPrdAction.setSelectedQuestionGroupsOnSession(
       request, loanOfferingBO, questionnaireServiceFacade);
   List<QuestionGroupDetail> questionGroupDetailList =
       (List<QuestionGroupDetail>)
           flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
   assertThat(questionGroupDetailList, is(notNullValue()));
   assertThat(questionGroupDetailList.size(), is(2));
   assertQuestionGroup(questionGroupDetailList.get(0), 1, "QG1");
   assertQuestionGroup(questionGroupDetailList.get(1), 2, "QG2");
   verify(questionnaireServiceFacade, times(3)).getQuestionGroupDetail(anyInt());
   verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
   verify(request, times(1)).getSession();
   verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
 }
 @Test
 public void shouldSetQuestionGroupsOnSession() throws PageExpiredException {
   List<QuestionGroupDetail> questionGroupDetails =
       asList(
           getQuestionGroupDetail(1, "QG1", true),
           getQuestionGroupDetail(2, "QG2", true),
           getQuestionGroupDetail(3, "QG3", true));
   when(questionnaireServiceFacade.getQuestionGroups("Create", "Loan"))
       .thenReturn(questionGroupDetails);
   when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
   when(request.getSession()).thenReturn(session);
   when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
   Flow flow = new Flow();
   when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
   loanPrdAction.setQuestionGroupsOnSession(request, questionnaireServiceFacade);
   assertThat(
       (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SRCQGLIST),
       is(questionGroupDetails));
   verify(questionnaireServiceFacade, times(1)).getQuestionGroups("Create", "Loan");
   verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
   verify(request, times(1)).getSession();
   verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
 }