ClientCustAction extends CustAction implements QuestionnaireAction { private void setQuestionGroupInstances(HttpServletRequest request, ClientBO clientBO) throws PageExpiredException { QuestionnaireServiceFacade questionnaireServiceFacade = questionnaireServiceFacadeLocator.getService(request); boolean containsQGForCloseClient = false; if (questionnaireServiceFacade != null) { setQuestionGroupInstances(questionnaireServiceFacade, request, clientBO.getCustomerId()); if (clientBO.getCustomerStatus().getId().equals(CustomerStatus.CLIENT_CLOSED.getValue())) { containsQGForCloseClient = questionnaireServiceFacade.getQuestionGroupInstances(clientBO.getCustomerId(), "Close", "Client").size() > 0; } } SessionUtils.removeThenSetAttribute("containsQGForCloseClient", containsQGForCloseClient, request); }  @TransactionDemarcate(saveToken = true) ActionForward chooseOffice(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                      @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(saveToken = true) ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward addFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward deleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward next(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                              @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward familyInfoNext(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                        @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward addFamilyRow(ActionMapping mapping, ActionForm form,
                                      @SuppressWarnings("unused") HttpServletRequest request,
                                      @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward deleteFamilyRow(ActionMapping mapping, ActionForm form,
                                         @SuppressWarnings("unused") HttpServletRequest request,
                                         @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editAddFamilyRow(ActionMapping mapping, ActionForm form,
                                          @SuppressWarnings("unused") HttpServletRequest request,
                                          @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editDeleteFamilyRow(ActionMapping mapping, ActionForm form,
                                             @SuppressWarnings("unused") HttpServletRequest request,
                                             @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                 @SuppressWarnings("unused") HttpServletResponse response); ActionForward cancel(ActionMapping mapping, ActionForm form,
                                @SuppressWarnings("unused") HttpServletRequest request,
                                @SuppressWarnings("unused") HttpServletResponse response); ActionForward editPreviewEditFamilyInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                                   @SuppressWarnings("unused") HttpServletRequest request,
                                                   @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward retrievePictureOnPreview(ActionMapping mapping, ActionForm form,
                                                  @SuppressWarnings("unused") HttpServletRequest request, HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward retrievePicture(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
            HttpServletRequest request, HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward previewPersonalInfo(ActionMapping mapping, ActionForm form,
            @SuppressWarnings("unused") HttpServletRequest request,
            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward prevFamilyInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                        @SuppressWarnings("unused") HttpServletRequest request,
                                        @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevFamilyInfoNext(ActionMapping mapping, ActionForm form,
                                            @SuppressWarnings("unused") HttpServletRequest request,
                                            @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevPersonalInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                          @SuppressWarnings("unused") HttpServletRequest request,
                                          @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevMFIInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                     @SuppressWarnings("unused") HttpServletRequest request,
                                     @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevMeeting(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                     @SuppressWarnings("unused") HttpServletRequest request,
                                     @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward loadMeeting(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                     @SuppressWarnings("unused") HttpServletRequest request,
                                     @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(validateAndResetToken = true) ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward validate(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                  HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(saveToken = true) ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                             @SuppressWarnings("unused") HttpServletResponse response); void setQuestionGroupInstances(QuestionnaireServiceFacade questionnaireServiceFacade, HttpServletRequest request, Integer customerId); @TransactionDemarcate(joinToken = true) ActionForward showPicture(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                     @SuppressWarnings("unused") HttpServletRequest request,
                                     @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editPersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                          @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward previewEditPersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                                 @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevEditPersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                              @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @CloseSession @TransactionDemarcate(validateAndResetToken = true) ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                            @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                        @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward previewEditFamilyInfo(ActionMapping mapping, ActionForm form,
                                               @SuppressWarnings("unused") HttpServletRequest request,
                                               @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @CloseSession @TransactionDemarcate(validateAndResetToken = true) ActionForward updateFamilyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                          @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward editMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                     @SuppressWarnings("unused") HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward previewEditMfiInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                            @SuppressWarnings("unused") HttpServletRequest request,
                                            @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @TransactionDemarcate(joinToken = true) ActionForward prevEditMfiInfo(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
                                         @SuppressWarnings("unused") HttpServletRequest request,
                                         @SuppressWarnings("unused") HttpServletResponse httpservletresponse); @CloseSession @TransactionDemarcate(validateAndResetToken = true) ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                       @SuppressWarnings("unused") HttpServletResponse response); @Override ActionForward captureQuestionResponses(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response); @Override ActionForward editQuestionResponses(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response);  }
@Test public void shouldSetQuestionGroupInstanceDetailsInSession() throws PageExpiredException { List<QuestionGroupInstanceDetail> instanceDetails = asList(getQuestionGroupInstanceDetail("QG1"), getQuestionGroupInstanceDetail("QG2")); when(questionnaireServiceFacade.getQuestionGroupInstances(101, "View", "Client")).thenReturn(instanceDetails); 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); clientCustAction.setQuestionGroupInstances(questionnaireServiceFacade, request, 101); assertThat((List<QuestionGroupInstanceDetail>) flow.getObjectFromSession("questionGroupInstances"), is(instanceDetails)); verify(questionnaireServiceFacade, times(1)).getQuestionGroupInstances(101, "View", "Client"); verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY); verify(request, times(1)).getSession(); verify(session, times(1)).getAttribute(Constants.FLOWMANAGER); }