Search in sources :

Example 1 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class FeeBOTest method testInvalidConnectionThrowsExceptionInConstructor.

@Test
@ExpectedException(value = FeeException.class)
public void testInvalidConnectionThrowsExceptionInConstructor() throws PersistenceException {
    final OfficePersistence officePersistence = mock(OfficePersistence.class);
    try {
        when(officePersistence.getHeadOffice()).thenThrow(new PersistenceException("some exception"));
        new RateFeeBO(null, "Customer Fee", new CategoryTypeEntity(FeeCategory.CENTER), new FeeFrequencyTypeEntity(FeeFrequencyType.ONETIME), null, 2.0, null, false, new FeePaymentEntity(FeePayment.UPFRONT)) {

            @Override
            public OfficePersistence getOfficePersistence() {
                return officePersistence;
            }
        };
        Assert.fail("should fail because of invalid session");
    } catch (FeeException e) {
    }
}
Also used : FeeException(org.mifos.accounts.fees.exceptions.FeeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 2 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetApplicableProductCategories.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetApplicableProductCategories() throws PersistenceException {
    try {
        when(prdOfferingPersistence.getApplicableProductCategories(ProductType.LOAN, PrdCategoryStatus.ACTIVE)).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getActiveLoanProductCategories();
        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 3 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class ProductCategoryBusinessServiceTest method testInvalidConnectionGetProductCategoryStatusList.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionGetProductCategoryStatusList() throws PersistenceException {
    try {
        when(productCategoryPersistence.getProductCategoryStatusList()).thenThrow(new PersistenceException("some exception"));
        service.getProductCategoryStatusList();
        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 4 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class ProductCategoryBusinessServiceTest method testInvalidConnectionGetAllCategories.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionGetAllCategories() throws PersistenceException {
    try {
        when(productCategoryPersistence.getAllCategories()).thenThrow(new PersistenceException("some exception"));
        service.getAllCategories();
        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 5 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class ProductCategoryBusinessServiceTest method testInvalidConnectionForFindByGlobalNum.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionForFindByGlobalNum() throws PersistenceException {
    String globalNum = "globalNum";
    try {
        when(productCategoryPersistence.findByGlobalNum(globalNum)).thenThrow(new PersistenceException("some exception"));
        service.findByGlobalNum(globalNum);
        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

Test (org.junit.Test)32 PersistenceException (org.mifos.framework.exceptions.PersistenceException)32 ExpectedException (org.springframework.test.annotation.ExpectedException)32 ServiceException (org.mifos.framework.exceptions.ServiceException)29 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 AccountException (org.mifos.accounts.exceptions.AccountException)1 FeeException (org.mifos.accounts.fees.exceptions.FeeException)1 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 UserContext (org.mifos.security.util.UserContext)1