Search in sources :

Example 26 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation() throws Exception {
    // setup
    OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxx-9999").build();
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.CENTER_INACTIVE).build();
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
    when(mockedCenter.getOffice()).thenReturn(office);
    when(mockedCenter.getCustomerStatus()).thenReturn(new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE));
    doThrow(new CustomerException(CustomerConstants.CENTER_STATE_CHANGE_EXCEPTION)).when(mockedCenter).validateChangeToInActive();
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    // verification
    verify(mockedCenter).validateChangeToInActive();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 27 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CheckListBOIntegrationTest method testCreateCheckListExceptionForCustomerZeroDetails.

@Test
public void testCreateCheckListExceptionForCustomerZeroDetails() throws Exception {
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.CENTER);
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE);
    try {
        customerCheckList = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, null, CheckListConstants.STATUS_ACTIVE, new ArrayList<String>(), (short) 1, (short) 1);
        Assert.fail();
    } catch (CheckListException ce) {
        Assert.assertTrue(true);
    }
}
Also used : CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) ArrayList(java.util.ArrayList) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) Test(org.junit.Test)

Example 28 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class ProcessFlowRules method initFromDB.

public static void initFromDB() {
    MifosConfigurationManager cm = MifosConfigurationManager.getInstance();
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    CustomerStatusEntity cse = customerDao.findClientPendingStatus();
    cm.setProperty(CLIENT_PENDING_APPROVAL, isClientPendingApprovalStateEnabledOnDatabaseConfiguration(cse));
    cse = customerDao.findGroupPendingStatus();
    cm.setProperty(GROUP_PENDING_APPROVAL, isGroupPendingApprovalStateEnabledOnDatabaseConfiguration(cse));
    AccountStateEntity ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.LOAN_PENDING_APPROVAL.getValue());
    cm.setProperty(LOAN_PENDING_APPROVAL, isLoanPendingApprovalStateEnabledOnDatabaseConfig(ase));
    ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.SAVINGS_PENDING_APPROVAL.getValue());
    cm.setProperty(SAVINGS_PENDING_APPROVAL, isSavingPendingApprovalStateEnabledOnDatabaseConfig(ase));
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 29 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class ProcessFlowRules method initGroupPendingApprovalState.

private static void initGroupPendingApprovalState() throws ConfigurationException {
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    CustomerStatusEntity cse = customerDao.findGroupPendingStatus();
    boolean fromDb = isGroupPendingApprovalStateEnabledOnDatabaseConfiguration(cse);
    boolean fromCfg = isGroupPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = customerDao.countOfGroups();
        if (count > 0) {
            final String errMsg = getBadOverrideMsg(GROUP_PENDING_APPROVAL, "Records for groups in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(customerDao, cse, fromCfg);
    }
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao)

Example 30 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class ProcessFlowRules method initClientPendingApprovalState.

private static void initClientPendingApprovalState() throws ConfigurationException {
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    CustomerStatusEntity cse = customerDao.findClientPendingStatus();
    boolean fromDb = isClientPendingApprovalStateEnabledOnDatabaseConfiguration(cse);
    boolean fromCfg = isClientPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = customerDao.countOfClients();
        if (count > 0) {
            final String errMsg = getBadOverrideMsg(CLIENT_PENDING_APPROVAL, "Records for clients in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(customerDao, cse, fromCfg);
    }
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao)

Aggregations

CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)30 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 PersistenceException (org.mifos.framework.exceptions.PersistenceException)6 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)6 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)5 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)5 HashMap (java.util.HashMap)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 UserContext (org.mifos.security.util.UserContext)4 StateEntity (org.mifos.application.master.business.StateEntity)3 CustomerStatusFlagEntity (org.mifos.customers.business.CustomerStatusFlagEntity)3 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)3 ClientBO (org.mifos.customers.client.business.ClientBO)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 CustomerDao (org.mifos.customers.persistence.CustomerDao)3 ListElement (org.mifos.dto.screen.ListElement)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2