@SuppressWarnings({"ThrowableInstanceNeverThrown"})

@Test
public void testCreateQuestionGroupFailure() throws Exception {
    QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client", "S1", "S2");
    when(requestContext.getMessageContext()).thenReturn(messageContext);
    doThrow(new SystemException("questionnaire.error.duplicate.question.found.in.section")).when(questionnaireServiceFacade).createActiveQuestionGroup(Matchers.<QuestionGroupDetail>anyObject());
    String result = questionGroupController.defineQuestionGroup(questionGroupForm, requestContext, true);
    assertThat(result, Is.is("failure"));
    verify(questionnaireServiceFacade).createActiveQuestionGroup(Matchers.<QuestionGroupDetail>anyObject());
    verify(requestContext).getMessageContext();
    verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.duplicate.question.found.in.section")));
}