Search in sources :

Example 96 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 97 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 98 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)

Example 99 with PersistenceException

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

the class GroupBusinessServiceTest method testInvalidConnectionInGetGroup.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetGroup() throws PersistenceException {
    try {
        Integer customerId = new Integer(1);
        when(groupPersistence.getGroupByCustomerId(customerId)).thenThrow(new PersistenceException("some exception"));
        service.getGroup(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) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 100 with PersistenceException

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

the class GroupBusinessServiceTest method testInvalidConnectionInFindBySystemId.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInFindBySystemId() throws PersistenceException {
    try {
        String globalCustNo = "globalCustNo";
        when(groupPersistence.findBySystemId(globalCustNo)).thenThrow(new PersistenceException("some exception"));
        service.findBySystemId(globalCustNo);
        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)

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