use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.
the class AuditBusinessServiceIntegrationTest method testGetAuditLogRecordsPasswordChange.
@Test
public void testGetAuditLogRecordsPasswordChange() throws Exception {
AuditLog auditLog = new AuditLog(1, (short) 2, "Mifos", new Date(System.currentTimeMillis()), (short) 3);
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
AuditLogRecord auditLogRecord = new AuditLogRecord("Password", "test_1", "new_test_1", auditLog);
auditLogRecords.add(auditLogRecord);
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
AuditBusinessService auditBusinessService = new AuditBusinessService();
List<AuditLogView> auditLogViewList = auditBusinessService.getAuditLogRecords((short) 2, 1);
Assert.assertEquals(1, auditLogViewList.size());
AuditLogView auditLogView = auditLogViewList.get(0);
Assert.assertEquals(AuditConstants.HIDDEN_PASSWORD, auditLogView.getOldValue());
Assert.assertEquals(AuditConstants.HIDDEN_PASSWORD, auditLogView.getNewValue());
auditLog = getAuditLog(1, (short) 2);
}
use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.
the class AuditPersistenceIntegrationTest method testSave.
@Test
public void testSave() {
AuditLog auditLog = new AuditLog(Integer.valueOf("1"), Short.valueOf("2"), "Mifos", new Date(System.currentTimeMillis()), Short.valueOf("3"));
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
AuditLogRecord auditLogRecord = new AuditLogRecord("ColumnName_1", "test_1", "new_test_1", auditLog);
auditLogRecords.add(auditLogRecord);
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
auditLog = getAuditLog(Integer.valueOf("1"), Short.valueOf("2"));
Assert.assertEquals(Integer.valueOf("1"), auditLog.getEntityId());
Assert.assertEquals(Short.valueOf("2"), auditLog.getEntityType());
Assert.assertEquals("Mifos", auditLog.getModifierName());
Assert.assertEquals("Mifos", auditLog.getModifierName());
Assert.assertEquals(1, auditLog.getAuditLogRecords().size());
for (AuditLogRecord logRecord : auditLog.getAuditLogRecords()) {
Assert.assertEquals("ColumnName_1", logRecord.getFieldName());
Assert.assertEquals("test_1", logRecord.getOldValue());
Assert.assertEquals("new_test_1", logRecord.getNewValue());
}
}
use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.
the class AuditPersistenceIntegrationTest method testGetAuditLogRecords.
@Test
public void testGetAuditLogRecords() throws Exception {
AuditLog auditLog = new AuditLog(Integer.valueOf("1"), Short.valueOf("2"), "Mifos", new Date(System.currentTimeMillis()), Short.valueOf("3"));
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
AuditLogRecord auditLogRecord = new AuditLogRecord("ColumnName_1", "test_1", "new_test_1", auditLog);
auditLogRecords.add(auditLogRecord);
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
auditLog = getAuditLog(Integer.valueOf("1"), Short.valueOf("2"));
List<AuditLog> auditLogList = legacyAuditDao.getAuditLogRecords(Short.valueOf("2"), Integer.valueOf("1"));
Assert.assertEquals(1, auditLogList.size());
}
use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.
the class AuditInterceptorIntegrationTest method testUpdateLoanForLogging.
/*
* Note: since this loan is active the disbursement date will not be updated
*/
@Test
public void testUpdateLoanForLogging() throws Exception {
Date newDate = incrementCurrentDate(14);
accountBO = getLoanAccount();
accountBO.setUserContext(TestUtils.makeUser());
((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(accountBO);
LoanBO loanBO = ((LoanBO) accountBO);
((LoanBO) accountBO).updateLoan(true, loanBO.getLoanAmount(), loanBO.getInterestRate(), loanBO.getNoOfInstallments(), newDate, (short) 2, TestObjectFactory.SAMPLE_BUSINESS_ACTIVITY_2, "Added note", null, null, false, null, null);
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getCustomer(group.getCustomerId());
accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId());
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
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("Collateral Notes")) {
Assert.assertEquals("-", auditLogRecord.getOldValue());
Assert.assertEquals("Added note", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Service Charge deducted At Disbursement")) {
Assert.assertEquals("1", auditLogRecord.getOldValue());
Assert.assertEquals("0", auditLogRecord.getNewValue());
}
}
accountBO = null;
group = null;
center = null;
}
use of org.mifos.framework.components.audit.business.AuditLogRecord 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");
}
}
}
Aggregations