Search in sources :

Example 66 with PersistenceException

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

the class PersonnelBusinessServiceTest method testInvalidConnectionInGetActiveLoanOfficersUnderOffice.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetActiveLoanOfficersUnderOffice() throws PersistenceException {
    try {
        when(personnelPersistence.getActiveLoanOfficersUnderOffice(id)).thenThrow(new PersistenceException("some exception"));
        service.getActiveLoanOfficersUnderOffice(id);
        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 67 with PersistenceException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetRole.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetRole() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getRole(id)).thenThrow(new PersistenceException("some exception"));
        service.getRole(id);
        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 68 with PersistenceException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetRoles.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetRoles() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getRoles()).thenThrow(new PersistenceException("some exception"));
        service.getRoles();
        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 69 with PersistenceException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetActivities.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetActivities() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getActivities()).thenThrow(new PersistenceException("some exception"));
        service.getActivities();
        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 70 with PersistenceException

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

the class AdminDocumentsServiceImpl method getAdminDocumentsForAccountPayment.

@Override
public List<AdminDocumentDto> getAdminDocumentsForAccountPayment(Integer paymentId) {
    try {
        List<AdminDocumentDto> adminDocuments = new ArrayList<AdminDocumentDto>();
        AccountPaymentEntity accountPaymentEntity = legacyAccountDao.findPaymentById(paymentId);
        Set<AccountTrxnEntity> accountTrxnEntities = accountPaymentEntity.getAccountTrxns();
        for (AccountTrxnEntity accountTrxnEntity : accountTrxnEntities) {
            List<AdminDocumentBO> adminDocumentBOs = legacyAdminDocumentDao.getActiveAdminDocumentsByAccountActionId(accountTrxnEntity.getAccountActionEntity().getId());
            if (adminDocumentBOs != null && !adminDocumentBOs.isEmpty()) {
                for (AdminDocumentBO adminDocumentBO : adminDocumentBOs) {
                    AdminDocumentDto adminDocumentDto = new AdminDocumentDto(adminDocumentBO.getAdmindocId().intValue(), adminDocumentBO.getAdminDocumentName(), adminDocumentBO.getAdminDocumentIdentifier(), BooleanUtils.toBoolean(adminDocumentBO.getIsActive().intValue()));
                    if (!adminDocuments.contains(adminDocumentDto)) {
                        adminDocuments.add(adminDocumentDto);
                    }
                }
            }
        }
        return adminDocuments;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AdminDocumentDto(org.mifos.dto.domain.AdminDocumentDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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