Search in sources :

Example 56 with PersistenceException

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

the class CustomerBusinessServiceTest method testInvalidConnectionGetCustomer.

@Test
public void testInvalidConnectionGetCustomer() throws PersistenceException {
    Integer customerId = new Integer(1);
    try {
        when(customerPersistence.getCustomer(customerId)).thenThrow(new PersistenceException("some exception"));
        service.getCustomer(customerId);
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test)

Example 57 with PersistenceException

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

the class CenterBOTest method testInvalidConnectionInConstructor.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInConstructor() throws PersistenceException {
    try {
        Short id = new Short("1");
        OfficeBO office = mock(OfficeBO.class);
        when(office.getOfficeId()).thenReturn(id);
        when(customerPersistence.getCustomerCountForOffice(CustomerLevel.CENTER, id)).thenThrow(new PersistenceException("some exception"));
        new CenterBO(mock(UserContext.class), "name", null, null, null, "externalId", null, office, mock(MeetingBO.class), mock(PersonnelBO.class), customerPersistence);
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (CustomerException e) {
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 58 with PersistenceException

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

the class CheckListBusinessServiceTest method testInvalidConnectionRetrieveAllAccountCheckLists.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionRetrieveAllAccountCheckLists() throws PersistenceException {
    try {
        when(checkListPersistence.retreiveAllAccountCheckLists()).thenThrow(new PersistenceException("some exception"));
        service.retreiveAllAccountCheckLists();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 59 with PersistenceException

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

the class CheckListBusinessServiceTest method testInvalidConnectionRetrieveAllCustomerCheckLists.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionRetrieveAllCustomerCheckLists() throws PersistenceException {
    try {
        when(checkListPersistence.retreiveAllCustomerCheckLists()).thenThrow(new PersistenceException("some exception"));
        service.retreiveAllCustomerCheckLists();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 60 with PersistenceException

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

the class TestObjectFactory method generateOfficeGlobalNo.

private static String generateOfficeGlobalNo() throws OfficeException {
    try {
        /*
             * TODO: Why not auto-increment? Fetching the max and adding one would seem to have a race condition.
             */
        String officeGlobelNo = String.valueOf(new OfficePersistence().getMaxOfficeId().intValue() + 1);
        if (officeGlobelNo.length() > 4) {
            throw new OfficeException(OfficeConstants.MAXOFFICELIMITREACHED);
        }
        StringBuilder temp = new StringBuilder("");
        for (int i = officeGlobelNo.length(); i < 4; i++) {
            temp.append("0");
        }
        return officeGlobelNo = temp.append(officeGlobelNo).toString();
    } catch (PersistenceException e) {
        throw new OfficeException(e);
    }
}
Also used : OfficeException(org.mifos.customers.office.exceptions.OfficeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence)

Aggregations

PersistenceException (org.mifos.framework.exceptions.PersistenceException)215 MifosRuntimeException (org.mifos.core.MifosRuntimeException)98 ArrayList (java.util.ArrayList)55 ServiceException (org.mifos.framework.exceptions.ServiceException)53 AccountException (org.mifos.accounts.exceptions.AccountException)40 Test (org.junit.Test)35 ExpectedException (org.springframework.test.annotation.ExpectedException)32 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)24 BusinessRuleException (org.mifos.service.BusinessRuleException)23 Money (org.mifos.framework.util.helpers.Money)22 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)20 MifosUser (org.mifos.security.MifosUser)19 UserContext (org.mifos.security.util.UserContext)19 HashMap (java.util.HashMap)18 HibernateException (org.hibernate.HibernateException)18 Query (org.hibernate.Query)18 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 Session (org.hibernate.Session)14 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)14 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)14