@SuppressWarnings({"ThrowableInstanceNeverThrown"}) @Test public void testCreateQuestionFailure() throws Exception { QuestionForm questionForm = getQuestionForm(TITLE, "numeric"); when(requestContext.getMessageContext()).thenReturn(messageContext); Mockito.doThrow(new SystemException("db.write.failure")).when(questionnaireServiceFacade).createQuestions(Matchers.<List<QuestionDetail>>anyObject()); String result = questionController.createQuestions(questionForm, requestContext); Assert.assertThat(result, is("failure")); Mockito.verify(questionnaireServiceFacade).createQuestions(Matchers.<List<QuestionDetail>>anyObject()); Mockito.verify(requestContext).getMessageContext(); Mockito.verify(messageContext).addMessage(argThat(new MessageMatcher("db.write.failure"))); }
public String createQuestions(QuestionForm questionForm, RequestContext requestContext) { String result = "success"; try { questionnaireServiceFacade.createQuestions(getQuestionDetails(questionForm)); } catch (SystemException e) { constructAndLogSystemError(requestContext.getMessageContext(), e); result = "failure"; } return result; }
QuestionController extends QuestionnaireController { public String createQuestions(QuestionForm questionForm, RequestContext requestContext) { String result = "success"; try { questionnaireServiceFacade.createQuestions(getQuestionDetails(questionForm)); } catch (SystemException e) { constructAndLogSystemError(requestContext.getMessageContext(), e); result = "failure"; } return result; } }
QuestionController extends QuestionnaireController { public String createQuestions(QuestionForm questionForm, RequestContext requestContext) { String result = "success"; try { questionnaireServiceFacade.createQuestions(getQuestionDetails(questionForm)); } catch (SystemException e) { constructAndLogSystemError(requestContext.getMessageContext(), e); result = "failure"; } return result; } @SuppressWarnings({"UnusedDeclaration"})  QuestionController();  QuestionController(QuestionnaireServiceFacade questionnaireServiceFacade); }
QuestionController extends QuestionnaireController { public String createQuestions(QuestionForm questionForm, RequestContext requestContext) { String result = "success"; try { questionnaireServiceFacade.createQuestions(getQuestionDetails(questionForm)); } catch (SystemException e) { constructAndLogSystemError(requestContext.getMessageContext(), e); result = "failure"; } return result; } @SuppressWarnings({"UnusedDeclaration"})  QuestionController();  QuestionController(QuestionnaireServiceFacade questionnaireServiceFacade); @RequestMapping("/viewQuestions.ftl") String getAllQuestions(ModelMap model); String addQuestion(QuestionForm questionForm, RequestContext requestContext, boolean createMode); String addSmartChoiceTag(QuestionForm questionForm, RequestContext requestContext, int choiceIndex); void removeQuestion(QuestionForm questionForm, String questionTitle); String createQuestions(QuestionForm questionForm, RequestContext requestContext); }
QuestionController extends QuestionnaireController { public String createQuestions(QuestionForm questionForm, RequestContext requestContext) { String result = "success"; try { questionnaireServiceFacade.createQuestions(getQuestionDetails(questionForm)); } catch (SystemException e) { constructAndLogSystemError(requestContext.getMessageContext(), e); result = "failure"; } return result; } @SuppressWarnings({"UnusedDeclaration"})  QuestionController();  QuestionController(QuestionnaireServiceFacade questionnaireServiceFacade); @RequestMapping("/viewQuestions.ftl") String getAllQuestions(ModelMap model); String addQuestion(QuestionForm questionForm, RequestContext requestContext, boolean createMode); String addSmartChoiceTag(QuestionForm questionForm, RequestContext requestContext, int choiceIndex); void removeQuestion(QuestionForm questionForm, String questionTitle); String createQuestions(QuestionForm questionForm, RequestContext requestContext);  }