use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class EditStatusActionStrutsTest method updateSuccessForLoan.
@Ignore("Convert to unit test")
public void updateSuccessForLoan() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
// createInitialObjects();
createCenterGroupClientHierarchy();
accountBO = getLoanAccount(client, meeting, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "load");
addRequestParameter("input", "loan");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward("load_success");
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "preview");
addRequestParameter("input", "loan");
addRequestParameter("notes", "Test");
addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
addRequestParameter("newStatusId", "8");
addRequestParameter("flagId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward("preview_success");
StaticHibernateUtil.flushSession();
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "update");
addRequestParameter("notes", "Test");
addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
addRequestParameter("newStatusId", "8");
addRequestParameter("flagId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.loan_detail_page.toString());
verifyNoActionErrors();
verifyNoActionMessages();
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOAN, accountBO.getAccountId());
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.LOAN.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(3, auditLogList.get(0).getAuditLogRecords().size());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Explanation")) {
Assert.assertEquals("-", auditLogRecord.getOldValue());
Assert.assertEquals("Withdraw", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
Assert.assertEquals("Active in Good Standing", auditLogRecord.getOldValue());
Assert.assertEquals("Closed- Rescheduled", auditLogRecord.getNewValue());
}
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class LegacyMasterDaoIntegrationTest method testRetrieveMasterDataEntity.
@Test
public void testRetrieveMasterDataEntity() throws Exception {
List<AccountStateEntity> masterDataList = legacyMasterDao.findMasterDataEntities(AccountStateEntity.class);
Assert.assertEquals(18, masterDataList.size());
for (MasterDataEntity masterDataEntity : masterDataList) {
for (LookUpValueLocaleEntity lookUpValueLocaleEntity : masterDataEntity.getLookUpValue().getLookUpValueLocales()) {
Assert.assertEquals(Short.valueOf("1"), lookUpValueLocaleEntity.getLocaleId());
}
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class CheckListBOIntegrationTest method testUpdateAccountCheckListInvalidState.
@Test
public void testUpdateAccountCheckListInvalidState() throws Exception {
AccountCheckListBO accountCheckList1 = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_APPROVED, CheckListConstants.STATUS_ACTIVE);
accountCheckList = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, CheckListConstants.STATUS_ACTIVE);
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
StaticHibernateUtil.flushSession();
accountCheckList = (AccountCheckListBO) TestObjectFactory.getObject(AccountCheckListBO.class, accountCheckList.getChecklistId());
try {
accountCheckList.update(accountCheckList.getProductTypeEntity(), accountStateEntity, "Account CheckList", CheckListConstants.STATUS_INACTIVE, getCheckListDetails(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
} finally {
TestObjectFactory.deleteChecklist(accountCheckList1);
StaticHibernateUtil.flushSession();
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class EditCustomerStatusActionStrutsTest method testUpdateCenterStatus.
@SuppressWarnings("unchecked")
@Test
public void testUpdateCenterStatus() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", center.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 1, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", center.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "14");
addRequestParameter("flagId", "");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNull("Since new Status is not cancel,so flag should be null.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request.getSession()));
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.center_detail_page.toString());
center = TestObjectFactory.getCustomer(center.getCustomerId());
Assert.assertFalse(center.isActive());
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class CheckListServiceFacadeWebTier method updateAccountChecklist.
@Override
public void updateAccountChecklist(Short checklistId, Short productId, Short stateId, Short checklistStatus, 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 accountCheckList = (AccountCheckListBO) new CheckListPersistence().getCheckList(checklistId);
accountCheckList.update(productTypeEntity, accountStateEntity, checklistName, checklistStatus, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(accountCheckList);
hibernateTransactionHelper.commitTransaction();
} catch (ServiceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (PersistenceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
Aggregations