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();
}
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);
}
}
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));
}
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);
}
}
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);
}
}
Aggregations