Search in sources :

Example 26 with ApplicationException

use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithBlankName.

@Test
public void cannotCreateCenterWithBlankName() {
    // setup
    center = new CenterBuilder().withName("").build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithBlankName");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SPECIFY_NAME));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 27 with ApplicationException

use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithoutALoanOfficer.

@Test
public void cannotCreateCenterWithoutALoanOfficer() {
    // setup
    PersonnelBO noLoanOfficer = null;
    center = new CenterBuilder().withName("center1").withLoanOfficer(noLoanOfficer).build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithoutALoanOfficer");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 28 with ApplicationException

use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithoutAMeeting.

@Test
public void cannotCreateCenterWithoutAMeeting() {
    // setup
    MeetingBuilder noMeetingBuilder = null;
    MeetingBO noMeeting = null;
    center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(noMeeting).with(noMeetingBuilder).build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    try {
        center.validateMeetingAndFees(noAccountFees);
        fail("cannotCreateCenterWithoutAMeeting");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SPECIFY_MEETING));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 29 with ApplicationException

use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithFeeThatHasDifferentPeriod.

@Test
public void cannotCreateCenterWithFeeThatHasDifferentPeriod() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
    MeetingBuilder aMonthlyMeeting = new MeetingBuilder().periodicFeeMeeting().monthly();
    AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aMonthlyMeeting).build();
    AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    // exercise test
    try {
        center.validateMeetingAndFees(centerAccountFees);
        fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
    }
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 30 with ApplicationException

use of org.mifos.framework.exceptions.ApplicationException in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithoutABranch.

@Test
public void cannotCreateCenterWithoutABranch() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder customerMeeting = new MeetingBuilder().customerMeeting();
    OfficeBO noBranch = null;
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(customerMeeting).withMfiJoiningDate(today).with(noBranch).build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithoutABranch");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.INVALID_OFFICE));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) OfficeBO(org.mifos.customers.office.business.OfficeBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

ApplicationException (org.mifos.framework.exceptions.ApplicationException)76 BusinessRuleException (org.mifos.service.BusinessRuleException)34 MifosRuntimeException (org.mifos.core.MifosRuntimeException)29 UserContext (org.mifos.security.util.UserContext)25 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 ArrayList (java.util.ArrayList)16 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)16 MifosUser (org.mifos.security.MifosUser)16 SystemException (org.mifos.framework.exceptions.SystemException)14 CustomerBO (org.mifos.customers.business.CustomerBO)10 ServiceException (org.mifos.framework.exceptions.ServiceException)10 Test (org.junit.Test)9 AccountException (org.mifos.accounts.exceptions.AccountException)9 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)9 CustomerException (org.mifos.customers.exceptions.CustomerException)9 HibernateException (org.hibernate.HibernateException)8 Session (org.hibernate.Session)7 LoanBO (org.mifos.accounts.loan.business.LoanBO)7 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)7 CenterBO (org.mifos.customers.center.business.CenterBO)7