@Test public void testSaveQuestionnaireSuccess() { String result = questionGroupController.saveQuestionnaire( getQuestionGroupDetails(), 1, requestContext); verify(questionnaireServiceFacade, times(1)).saveResponses(argThat(new QuestionGroupDetailsMatcher( new QuestionGroupDetails(1, 2, 3, asList( getQuestionGroupDetail(TITLE, "View", "Client", "S1", "S3")))))); assertThat(result, is("success")); }
public String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext) { QuestionGroupDetail questionGroupDetail = questionGroupDetails.getDetails().get(questionGroupIndex); try { questionnaireServiceFacade.saveResponses(new QuestionGroupDetails(questionGroupDetails.getCreatorId(), questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), Arrays.asList(questionGroupDetail))); } catch (ValidationException e) { if (e.hasChildExceptions()) { for (ValidationException validationException : e.getChildExceptions()) { if (validationException instanceof MandatoryAnswerNotFoundException) { populateError(requestContext, (MandatoryAnswerNotFoundException) validationException); } else if (validationException instanceof BadNumericResponseException) { populateError(requestContext, (BadNumericResponseException) validationException); } } } return "failure"; } return "success"; }
QuestionGroupController extends QuestionnaireController { public String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext) { QuestionGroupDetail questionGroupDetail = questionGroupDetails.getDetails().get(questionGroupIndex); try { questionnaireServiceFacade.saveResponses(new QuestionGroupDetails(questionGroupDetails.getCreatorId(), questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), Arrays.asList(questionGroupDetail))); } catch (ValidationException e) { if (e.hasChildExceptions()) { for (ValidationException validationException : e.getChildExceptions()) { if (validationException instanceof MandatoryAnswerNotFoundException) { populateError(requestContext, (MandatoryAnswerNotFoundException) validationException); } else if (validationException instanceof BadNumericResponseException) { populateError(requestContext, (BadNumericResponseException) validationException); } } } return "failure"; } return "success"; } }
QuestionGroupController extends QuestionnaireController { public String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext) { QuestionGroupDetail questionGroupDetail = questionGroupDetails.getDetails().get(questionGroupIndex); try { questionnaireServiceFacade.saveResponses(new QuestionGroupDetails(questionGroupDetails.getCreatorId(), questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), Arrays.asList(questionGroupDetail))); } catch (ValidationException e) { if (e.hasChildExceptions()) { for (ValidationException validationException : e.getChildExceptions()) { if (validationException instanceof MandatoryAnswerNotFoundException) { populateError(requestContext, (MandatoryAnswerNotFoundException) validationException); } else if (validationException instanceof BadNumericResponseException) { populateError(requestContext, (BadNumericResponseException) validationException); } } } return "failure"; } return "success"; } @SuppressWarnings({"UnusedDeclaration"})  QuestionGroupController();  QuestionGroupController(QuestionnaireServiceFacade questionnaireServiceFacade); }
QuestionGroupController extends QuestionnaireController { public String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext) { QuestionGroupDetail questionGroupDetail = questionGroupDetails.getDetails().get(questionGroupIndex); try { questionnaireServiceFacade.saveResponses(new QuestionGroupDetails(questionGroupDetails.getCreatorId(), questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), Arrays.asList(questionGroupDetail))); } catch (ValidationException e) { if (e.hasChildExceptions()) { for (ValidationException validationException : e.getChildExceptions()) { if (validationException instanceof MandatoryAnswerNotFoundException) { populateError(requestContext, (MandatoryAnswerNotFoundException) validationException); } else if (validationException instanceof BadNumericResponseException) { populateError(requestContext, (BadNumericResponseException) validationException); } } } return "failure"; } return "success"; } @SuppressWarnings({"UnusedDeclaration"})  QuestionGroupController();  QuestionGroupController(QuestionnaireServiceFacade questionnaireServiceFacade); @RequestMapping("/viewQuestionGroups.ftl") String getAllQuestionGroups(ModelMap model, HttpServletRequest request); @RequestMapping("/viewQuestionGroupDetail.ftl") String getQuestionGroup(ModelMap model, HttpServletRequest httpServletRequest); @RequestMapping(value="/getHiddenVisibleQuestions.ftl", method=RequestMethod.POST) @ResponseBody Map<String, Map<Integer, Boolean>> getHiddenVisibleQuestions(
            @RequestParam Integer questionId, @RequestParam String response); @RequestMapping(value="/hideAttachedQuestions.ftl", method=RequestMethod.POST) @ResponseBody Map<String, List<String>> hideAttachedQuestions(
            @RequestParam String questionsId, @RequestParam String sectionsId); @SuppressWarnings({"ThrowableInstanceNeverThrown"}) String defineQuestionGroup(QuestionGroupForm questionGroupForm, RequestContext requestContext, boolean createMode); Map<String, String> getAllQgEventSources(); QuestionLinkDetail setQuestionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, 
            String affectedQuestionId, String value, String additionalValue, String linkType, String linkTypeDisplay); SectionLinkDetail setSectionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, 
            String affectedSectionName, String value, String additionalValue, String linkType, String linkTypeDisplay); SectionQuestionDetail findQuestionDetailById(QuestionGroupDetail questionGroupDetail, String questionId); SectionQuestionDetail findQuestionDetailByNickname(QuestionGroupDetail questionGroupDetail, String nickname); SectionDetail findSectionDetailByName(QuestionGroupDetail questionGroupDetail, String sectionName); List<QuestionLinkDetail> setFilledQuestionDetailForQuestionLinks(List<QuestionLinkDetail> questionLinkDetails, QuestionGroupDetail questionGroupDetail); List<SectionLinkDetail> setFilledSectionDetailForQuestionLinks(List<SectionLinkDetail> sectionLinkDetails, QuestionGroupDetail questionGroupDetail); String addLink(QuestionGroupForm questionGroupForm,
            String sourceQuestionId, String linkType, String appliesTo,
            String affectedQuestionId, String affectedSectionName,
            String value, String additionalValue, Map<String, String> linkTypes, RequestContext requestContext); String removeLink(QuestionGroupForm questionGroupForm,
            String sourceQuestionId, String affectedQuestionId, String affectedSectionName, String value, String additionalValue, RequestContext requestContext); String addSection(QuestionGroupForm questionGroupForm, RequestContext requestContext); String deleteSection(QuestionGroupForm questionGroupForm, String sectionName); String deleteQuestion(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveQuestionUp(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveQuestionDown(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveSectionUp(QuestionGroupForm questionGroupForm, String sectionName); String moveSectionDown(QuestionGroupForm questionGroupForm, String sectionName); List<SectionQuestionDetail> getAllSectionQuestions(); List<SectionQuestionDetail> getAllSectionQuestions(QuestionGroupForm questionGroupForm); Map<String, String> getAllLinkTypes(); String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext); String addQuestion(QuestionGroupForm questionGroupForm, RequestContext requestContext); String addSmartChoiceTag(QuestionGroupForm questionGroupForm, RequestContext requestContext, int choiceIndex); }
QuestionGroupController extends QuestionnaireController { public String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext) { QuestionGroupDetail questionGroupDetail = questionGroupDetails.getDetails().get(questionGroupIndex); try { questionnaireServiceFacade.saveResponses(new QuestionGroupDetails(questionGroupDetails.getCreatorId(), questionGroupDetails.getEntityId(), questionGroupDetails.getEventSourceId(), Arrays.asList(questionGroupDetail))); } catch (ValidationException e) { if (e.hasChildExceptions()) { for (ValidationException validationException : e.getChildExceptions()) { if (validationException instanceof MandatoryAnswerNotFoundException) { populateError(requestContext, (MandatoryAnswerNotFoundException) validationException); } else if (validationException instanceof BadNumericResponseException) { populateError(requestContext, (BadNumericResponseException) validationException); } } } return "failure"; } return "success"; } @SuppressWarnings({"UnusedDeclaration"})  QuestionGroupController();  QuestionGroupController(QuestionnaireServiceFacade questionnaireServiceFacade); @RequestMapping("/viewQuestionGroups.ftl") String getAllQuestionGroups(ModelMap model, HttpServletRequest request); @RequestMapping("/viewQuestionGroupDetail.ftl") String getQuestionGroup(ModelMap model, HttpServletRequest httpServletRequest); @RequestMapping(value="/getHiddenVisibleQuestions.ftl", method=RequestMethod.POST) @ResponseBody Map<String, Map<Integer, Boolean>> getHiddenVisibleQuestions(
            @RequestParam Integer questionId, @RequestParam String response); @RequestMapping(value="/hideAttachedQuestions.ftl", method=RequestMethod.POST) @ResponseBody Map<String, List<String>> hideAttachedQuestions(
            @RequestParam String questionsId, @RequestParam String sectionsId); @SuppressWarnings({"ThrowableInstanceNeverThrown"}) String defineQuestionGroup(QuestionGroupForm questionGroupForm, RequestContext requestContext, boolean createMode); Map<String, String> getAllQgEventSources(); QuestionLinkDetail setQuestionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, 
            String affectedQuestionId, String value, String additionalValue, String linkType, String linkTypeDisplay); SectionLinkDetail setSectionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, 
            String affectedSectionName, String value, String additionalValue, String linkType, String linkTypeDisplay); SectionQuestionDetail findQuestionDetailById(QuestionGroupDetail questionGroupDetail, String questionId); SectionQuestionDetail findQuestionDetailByNickname(QuestionGroupDetail questionGroupDetail, String nickname); SectionDetail findSectionDetailByName(QuestionGroupDetail questionGroupDetail, String sectionName); List<QuestionLinkDetail> setFilledQuestionDetailForQuestionLinks(List<QuestionLinkDetail> questionLinkDetails, QuestionGroupDetail questionGroupDetail); List<SectionLinkDetail> setFilledSectionDetailForQuestionLinks(List<SectionLinkDetail> sectionLinkDetails, QuestionGroupDetail questionGroupDetail); String addLink(QuestionGroupForm questionGroupForm,
            String sourceQuestionId, String linkType, String appliesTo,
            String affectedQuestionId, String affectedSectionName,
            String value, String additionalValue, Map<String, String> linkTypes, RequestContext requestContext); String removeLink(QuestionGroupForm questionGroupForm,
            String sourceQuestionId, String affectedQuestionId, String affectedSectionName, String value, String additionalValue, RequestContext requestContext); String addSection(QuestionGroupForm questionGroupForm, RequestContext requestContext); String deleteSection(QuestionGroupForm questionGroupForm, String sectionName); String deleteQuestion(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveQuestionUp(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveQuestionDown(QuestionGroupForm questionGroupForm, String sectionName, String questionId); String moveSectionUp(QuestionGroupForm questionGroupForm, String sectionName); String moveSectionDown(QuestionGroupForm questionGroupForm, String sectionName); List<SectionQuestionDetail> getAllSectionQuestions(); List<SectionQuestionDetail> getAllSectionQuestions(QuestionGroupForm questionGroupForm); Map<String, String> getAllLinkTypes(); String saveQuestionnaire(QuestionGroupDetails questionGroupDetails, int questionGroupIndex, RequestContext requestContext); String addQuestion(QuestionGroupForm questionGroupForm, RequestContext requestContext); String addSmartChoiceTag(QuestionGroupForm questionGroupForm, RequestContext requestContext, int choiceIndex);  }