use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class ClientCustActionStrutsTest method testSuccessfulUpdatePersonalInfo_AuditLog.
@Test
public void testSuccessfulUpdatePersonalInfo_AuditLog() throws Exception {
createClientForAuditLog();
setRequestPathInfo("/clientCustAction.do");
addRequestParameter("method", "editPersonalInfo");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
List<BusinessActivityEntity> povertyStatusList = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
setRequestPathInfo("/clientCustAction.do");
addRequestParameter("method", "previewEditPersonalInfo");
addRequestParameter("clientName.salutation", Integer.valueOf("48").toString());
addRequestParameter("clientName.firstName", "Diti");
addRequestParameter("clientName.middleName", "S");
addRequestParameter("clientName.secondLastName", "S");
addRequestParameter("clientName.lastName", "Sharma");
addRequestParameter("spouseName.firstName", "Abc");
addRequestParameter("spouseName.middleName", "A");
addRequestParameter("spouseName.secondLastName", "A");
addRequestParameter("spouseName.lastName", "Sharma");
addRequestParameter("spouseName.nameType", "2");
addRequestParameter("clientDetailView.povertyStatus", povertyStatusList.get(1).getId().toString());
addRequestParameter("clientDetailView.gender", Integer.valueOf("50").toString());
addRequestParameter("clientDetailView.citizenship", Integer.valueOf("131").toString());
addRequestParameter("clientDetailView.ethnicity", Integer.valueOf("219").toString());
addRequestParameter("clientDetailView.handicapped", Integer.valueOf("139").toString());
addRequestParameter("clientDetailView.businessActivities", "");
addRequestParameter("clientDetailView.maritalStatus", Integer.valueOf("67").toString());
addRequestParameter("clientDetailView.educationLevel", Integer.valueOf("227").toString());
addRequestParameter("clientDetailView.numChildren", Integer.valueOf("2").toString());
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "11");
addRequestParameter("customField[" + i + "].fieldType", "1");
i++;
}
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.previewEditPersonalInfo_success.toString());
setRequestPathInfo("/clientCustAction.do");
addRequestParameter("method", "updatePersonalInfo");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.updatePersonalInfo_success.toString());
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertEquals(219, client.getCustomerDetail().getEthnicity().shortValue(), DELTA);
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.CLIENT, client.getCustomerId());
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.CLIENT.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(client.getCustomerId(), auditLogList.get(0).getEntityId());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Gender")) {
matchValues(auditLogRecord, "Male", "Female");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Ethnicity")) {
matchValues(auditLogRecord, "OBC", "FC");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Number Of Children")) {
matchValues(auditLogRecord, "1", "2");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Handicapped")) {
matchValues(auditLogRecord, "Yes", "No");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Marital Status")) {
matchValues(auditLogRecord, "Married", "UnMarried");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Education Level")) {
matchValues(auditLogRecord, "Both Literate", "Both Illiterate");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Poverty Status")) {
matchValues(auditLogRecord, "Very poor", "Poor");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Citizenship")) {
matchValues(auditLogRecord, "Hindu", "Muslim");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Business Activities")) {
matchValues(auditLogRecord, "Trading", "-");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Salutation")) {
matchValues(auditLogRecord, "Mr", "Mrs");
}
}
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class SavingsActionStrutsTest method testSuccessful_Update_AuditLog.
@Test
public void testSuccessful_Update_AuditLog() throws Exception {
createAndAddObjects(AccountState.SAVINGS_PARTIAL_APPLICATION);
savingsOffering = null;
addRequestParameter("recommendedAmount", "600.0");
setRequestPathInfo("/savingsAction.do");
addRequestParameter("method", "update");
actionPerform();
verifyForward("update_success");
String globalAccountNum = (String) request.getAttribute(SavingsConstants.GLOBALACCOUNTNUM);
Assert.assertNotNull(globalAccountNum);
StaticHibernateUtil.flushSession();
savings = savingsDao.findBySystemId(globalAccountNum);
Assert.assertNotNull(savings);
Assert.assertEquals(TestUtils.createMoney(600.0), savings.getRecommendedAmount());
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.SAVINGS, savings.getAccountId());
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.SAVINGS.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(savings.getAccountId(), auditLogList.get(0).getEntityId());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Recommended Amount")) {
matchValues(auditLogRecord, "300.0", "600.0");
// } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Additional Information")) {
// matchValues(auditLogRecord, "External Savings Id-custom field value", "External Savings Id-12");
}
}
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class SavingsOfferingBOIntegrationTest method testUpdateSavingsOfferingForLogging.
@Test
public void testUpdateSavingsOfferingForLogging() throws Exception {
String name = "Savings_offering";
String newName = "Savings_offeringChanged";
String shortName = "S";
String newShortName = "S1";
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
SavingsTypeEntity savingsType = new SavingsTypeEntity(SavingsType.MANDATORY);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(InterestCalcType.AVERAGE_BALANCE);
MeetingBO intCalcMeeting = getMeeting();
MeetingBO intPostMeeting = getMeeting();
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, (short) 2);
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(7);
savingsProduct = createSavingsOfferingBO(name, shortName, ApplicableTo.CLIENTS, startDate, PrdStatus.SAVINGS_ACTIVE, SavingsType.VOLUNTARY, InterestCalcType.MINIMUM_BALANCE);
savingsProduct.setUserContext(TestUtils.makeUserWithLocales());
((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(savingsProduct);
savingsProduct.update(Short.valueOf("1"), newName, newShortName, productCategory, prdApplicableMaster, startDate, endDate, "Desc", PrdStatus.SAVINGS_INACTIVE, null, savingsType, intCalType, intCalcMeeting, intPostMeeting, new Money(getCurrency(), "10"), new Money(getCurrency(), "100"), new Money(getCurrency(), "1"), 10.0);
StaticHibernateUtil.flushSession();
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
savingsProduct = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsProduct.getPrdOfferingId());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.SAVINGSPRODUCT, new Integer(savingsProduct.getPrdOfferingId().toString()));
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.SAVINGSPRODUCT, auditLogList.get(0).getEntityTypeAsEnum());
Set<AuditLogRecord> records = auditLogList.get(0).getAuditLogRecords();
Assert.assertEquals(12, records.size());
for (AuditLogRecord auditLogRecord : records) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Balance used for Interest rate calculation")) {
Assert.assertEquals("Minimum Balance", auditLogRecord.getOldValue());
Assert.assertEquals("Average Balance", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
Assert.assertEquals("Active", auditLogRecord.getOldValue());
Assert.assertEquals("Inactive", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Type Of Deposits")) {
Assert.assertEquals("Voluntary", auditLogRecord.getOldValue());
Assert.assertEquals("Mandatory", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Service Charge Rate")) {
Assert.assertEquals("1.2", auditLogRecord.getOldValue());
Assert.assertEquals("10.0", auditLogRecord.getNewValue());
} else {
// What are the others?
}
}
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class LoanOfferingBOIntegrationTest method testUpdateLoanOfferingFeeTypesForLogging.
@Test
public void testUpdateLoanOfferingFeeTypesForLogging() throws Exception {
createIntitalObjects();
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.MONTHLY, (short) 1);
List<FeeBO> fees = new ArrayList<FeeBO>();
fees.add(periodicFee);
product = createLoanOfferingBO("Loan Product", "LOAP");
((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(product);
product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, 12.0, 2.0, 12.0, false, false, true, null, fees, null, (short) 2, RecurrenceType.MONTHLY, populateLoanPrdActionForm("1", "1", new Double("3000"), new Double("1000"), new Double("1000"), "12", "1", "2"), waiverInterest, null);
StaticHibernateUtil.flushAndClearSession();
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
fees = new ArrayList<FeeBO>();
oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
fees.add(oneTimeFee);
product.setUserContext(TestUtils.makeUser());
((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(product);
product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, 12.0, 2.0, 12.0, false, true, false, null, fees, null, (short) 2, RecurrenceType.MONTHLY, populateLoanPrdActionForm("1", "1", new Double("3000"), new Double("1000"), new Double("1000"), "12", "1", "2"), waiverInterest, null);
StaticHibernateUtil.flushAndClearSession();
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOANPRODUCT, new Integer(product.getPrdOfferingId().toString()));
Assert.assertEquals(2, auditLogList.size());
Assert.assertEquals(EntityType.LOANPRODUCT.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(14, auditLogList.get(0).getAuditLogRecords().size());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Fee Types") && auditLogRecord.getNewValue().equalsIgnoreCase("Loan Periodic")) {
Assert.assertEquals("-", auditLogRecord.getOldValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Fee Types") && auditLogRecord.getNewValue().equalsIgnoreCase("Loan One time")) {
Assert.assertEquals("Loan Periodic", auditLogRecord.getOldValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Service Charge deducted At Disbursement")) {
Assert.assertEquals("1", auditLogRecord.getOldValue());
Assert.assertEquals("0", auditLogRecord.getNewValue());
}
}
}
Aggregations