Search in sources :

Example 71 with ServiceException

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

the class PersonnelBusinessServiceTest method testInvalidConnectionInSearch.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInSearch() throws PersistenceException {
    try {
        String searchStr = "shortname";
        when(personnelPersistence.search(searchStr, id)).thenThrow(new PersistenceException("some exception"));
        service.search(searchStr, 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 72 with ServiceException

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

the class PersonnelBusinessServiceTest 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 73 with ServiceException

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

the class PersonnelBusinessServiceTest method testInvalidConnectionInGetPersonnelByUsername.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetPersonnelByUsername() throws PersistenceException {
    try {
        String shortName = "shortname";
        when(personnelPersistence.getPersonnelByUserName(shortName)).thenThrow(new PersistenceException("some exception"));
        service.getPersonnel(shortName);
        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 74 with ServiceException

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

the class OfficeBusinessServiceTest method testInvalidConnectionInGetOffice.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetOffice() throws PersistenceException {
    try {
        when(officePersistence.getOffice(id)).thenThrow(new PersistenceException("some exception"));
        service.getOffice(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 75 with ServiceException

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

the class OfficeBusinessServiceTest method testInvalidConnectionInGetBranchOfficesUnderPersonnel.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetBranchOfficesUnderPersonnel() throws PersistenceException {
    try {
        PersonnelBO personnel = mock(PersonnelBO.class);
        String searchId = "somestr";
        when(personnel.getOfficeSearchId()).thenReturn(searchId);
        when(officePersistence.getActiveBranchesUnderUser(searchId)).thenThrow(new PersistenceException("some exception"));
        service.getActiveBranchesUnderUser(personnel);
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Aggregations

ServiceException (org.mifos.framework.exceptions.ServiceException)93 PersistenceException (org.mifos.framework.exceptions.PersistenceException)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)39 Test (org.junit.Test)34 ExpectedException (org.springframework.test.annotation.ExpectedException)29 ArrayList (java.util.ArrayList)24 UserContext (org.mifos.security.util.UserContext)19 AccountBO (org.mifos.accounts.business.AccountBO)17 MifosUser (org.mifos.security.MifosUser)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)15 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)14 AccountException (org.mifos.accounts.exceptions.AccountException)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 BusinessRuleException (org.mifos.service.BusinessRuleException)11 Date (java.util.Date)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 BigDecimal (java.math.BigDecimal)6 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)6 DateTimeService (org.mifos.framework.util.DateTimeService)6 LocalDate (org.joda.time.LocalDate)5