use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionnaireValidatorIntegrationTest method shouldCheckForInValidEventSource.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldCheckForInValidEventSource() {
EventSourceDto eventSourceDto = new EventSourceDto("Disburse", "Client", "Disburse Client");
try {
questionnaireValidator.validateForEventSource(eventSourceDto);
fail("Should have raised a validation error for invalid event");
} catch (SystemException e) {
assertThat(e.getKey(), is(QuestionnaireConstants.INVALID_EVENT_SOURCE));
}
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionnaireValidatorIntegrationTest method shouldCheckForValidEventSource.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldCheckForValidEventSource() {
EventSourceDto eventSourceDto = new EventSourceDto("Create", "Client", "Create Client");
try {
questionnaireValidator.validateForEventSource(eventSourceDto);
eventSourceDto = new EventSourceDto("View", "Client", "View Client");
questionnaireValidator.validateForEventSource(eventSourceDto);
eventSourceDto = new EventSourceDto("Create", "Loan", "Create Loan");
questionnaireValidator.validateForEventSource(eventSourceDto);
} catch (SystemException e) {
fail("Should not have raised a validation error for this event");
}
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionnaireValidatorTest method shouldThrowExceptionWhenEventSourceIsNotProvided.
@Test
public void shouldThrowExceptionWhenEventSourceIsNotProvided() {
try {
questionnaireValidator.validateForDefineQuestionGroup(new QuestionGroupDetail(0, "Title", null, asList(getSection("S1")), false));
fail("Should have thrown the validation exception");
} catch (SystemException e) {
assertEquals(INVALID_EVENT_SOURCE, e.getKey());
}
verify(eventSourceDao, never()).retrieveCountByEventAndSource(anyString(), anyString());
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionnaireValidatorTest method shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMaxBoundGiven.
@Test
public void shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMaxBoundGiven() {
try {
QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
questionDetail.setNumericMax(-100);
questionnaireValidator.validateForDefineQuestion(questionDetail);
} catch (SystemException e) {
fail("Should not have thrown the exception");
}
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionGroupControllerTest method testCreateQuestionGroupFailure.
@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")));
}
Aggregations