LoanPrdAction extends BaseAction { @SuppressWarnings("unchecked") public Set<QuestionGroupReference> getQuestionGroups(HttpServletRequest request) throws PageExpiredException { Set<QuestionGroupReference> questionGroupReferences = null; List<QuestionGroupDetail> questionGroups = (List<QuestionGroupDetail>) SessionUtils.getAttribute(ProductDefinitionConstants.SELECTEDQGLIST, request); if (CollectionUtils.isNotEmpty(questionGroups)) { questionGroupReferences = new LinkedHashSet<QuestionGroupReference>(questionGroups.size()); for (QuestionGroupDetail questionGroupDetail : questionGroups) { QuestionGroupReference questionGroupReference = new QuestionGroupReference(); questionGroupReference.setQuestionGroupId(questionGroupDetail.getId()); questionGroupReferences.add(questionGroupReference); } } return questionGroupReferences; } LoanPrdAction(); @TransactionDemarcate(saveToken = true) ActionForward load(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward previous(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(validateAndResetToken = true) ActionForward cancelCreate(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward validate(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(validateAndResetToken = true) ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @SuppressWarnings("unchecked") Set<QuestionGroupReference> getQuestionGroups(HttpServletRequest request); @TransactionDemarcate(joinToken = true) ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editPreview(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editPrevious(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @CloseSession @TransactionDemarcate(validateAndResetToken = true) ActionForward editCancel(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @CloseSession @TransactionDemarcate(validateAndResetToken = true) ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(saveToken = true) ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); void setSelectedQuestionGroupsOnSession(HttpServletRequest request, LoanOfferingBO loanOffering,
                                    QuestionnaireServiceFacade questionnaireServiceFacade); @TransactionDemarcate(saveToken = true) ActionForward viewAllLoanProducts(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); void setQuestionGroupsOnSession(HttpServletRequest request, QuestionnaireServiceFacade questionnaireServiceFacade);  }
@Test public void shouldGetQuestionGroupResponses() throws PageExpiredException { when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY); when(request.getSession()).thenReturn(session); when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager); List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", true)); when(flowManager.getFromFlow(FLOW_KEY, ProductDefinitionConstants.SELECTEDQGLIST)).thenReturn(questionGroupDetails); Set<QuestionGroupReference> questionGroupReferences = loanPrdAction.getQuestionGroups(request); assertThat(questionGroupReferences, is(notNullValue())); assertThat(questionGroupReferences.size(), is(3)); QuestionGroupReference[] qgReferences = questionGroupReferences.toArray(new QuestionGroupReference[questionGroupReferences.size()]); assertThat(qgReferences[0].getQuestionGroupId(), is(1)); assertThat(qgReferences[1].getQuestionGroupId(), is(2)); assertThat(qgReferences[2].getQuestionGroupId(), is(3)); verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY); verify(request, times(1)).getSession(); verify(session, times(1)).getAttribute(Constants.FLOWMANAGER); verify(flowManager, times(1)).getFromFlow(FLOW_KEY, ProductDefinitionConstants.SELECTEDQGLIST); }