Search in sources :

Example 1 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class ProductCategoryPersistenceIntegrationTest method testGetProductTypes.

@Test
public void testGetProductTypes() throws Exception {
    List<ProductTypeEntity> productTypeList = legacyProductCategoryDao.getProductTypes();
    Assert.assertEquals(2, productTypeList.size());
    for (ProductTypeEntity productTypeEntity : productTypeList) {
        if (productTypeEntity.getType() == ProductType.LOAN) {
            Assert.assertEquals("Loan", productTypeEntity.getName());
        } else {
            //Assert.assertEquals("Margin Money",productTypeEntity.getName());
            Assert.assertEquals("Savings", productTypeEntity.getName());
        }
    }
}
Also used : ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) Test(org.junit.Test)

Example 2 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class SavingsProductDaoHibernateIntegrationTest method testShouldFindSavingsProductConfiguration.

@Test
public void testShouldFindSavingsProductConfiguration() {
    // exercise test
    ProductTypeEntity productType = savingsProductDao.findSavingsProductConfiguration();
    assertThat(productType, is(notNullValue()));
    assertThat(productType.getType(), is(ProductType.SAVINGS));
}
Also used : ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) Test(org.junit.Test)

Example 3 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class ProductCategoryBusinessServiceIntegrationTest method testGetProductTypes.

@Test
public void testGetProductTypes() throws Exception {
    UserContext context = TestUtils.makeUser();
    List<ProductTypeEntity> productTypeList = productCategoryBusinessService.getProductTypes();
    Assert.assertEquals(2, productTypeList.size());
    for (ProductTypeEntity productTypeEntity : productTypeList) {
        if (productTypeEntity.getProductTypeID().equals(ProductType.LOAN.getValue())) {
            Assert.assertEquals("Loan", productTypeEntity.getName());
        } else {
            //Assert.assertEquals("Margin Money",productTypeEntity.getName());
            Assert.assertEquals("Savings", productTypeEntity.getName());
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) Test(org.junit.Test)

Example 4 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class LoanProductDaoHibernateIntegrationTest method testShouldFindLoanProductConfiguration.

@Test
public void testShouldFindLoanProductConfiguration() {
    // exercise test
    ProductTypeEntity productType = loanProductDao.findLoanProductConfiguration();
    assertThat(productType, is(notNullValue()));
    assertThat(productType.getType(), is(ProductType.LOAN));
}
Also used : ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) Test(org.junit.Test)

Example 5 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class CheckListServiceFacadeWebTier method createAccountChecklist.

@Override
public void createAccountChecklist(Short productId, Short stateId, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        ProductTypeEntity productTypeEntity = null;
        for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
            if (productId.equals(prdTypeEntity.getProductTypeID())) {
                productTypeEntity = prdTypeEntity;
                break;
            }
        }
        hibernateTransactionHelper.startTransaction();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
        AccountCheckListBO accountCheckListBO = new AccountCheckListBO(productTypeEntity, accountStateEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckListBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)13 Test (org.junit.Test)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 ServiceException (org.mifos.framework.exceptions.ServiceException)4 UserContext (org.mifos.security.util.UserContext)4 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)3 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)3 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 MifosUser (org.mifos.security.MifosUser)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 ArrayList (java.util.ArrayList)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)1 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 ProductCategoryTypeDto (org.mifos.dto.screen.ProductCategoryTypeDto)1 ProductConfigurationDto (org.mifos.dto.screen.ProductConfigurationDto)1