use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class ClientTransferActionStrutsTest method testSuccessful_transferToBranch_AuditLog.
@Test
public void testSuccessful_transferToBranch_AuditLog() throws Exception {
createObjectsForClientTransfer();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
setRequestPathInfo("/clientTransferAction.do");
addRequestParameter("method", "transferToBranch");
addRequestParameter("officeId", office.getOfficeId().toString());
addRequestParameter("officeName", office.getOfficeName());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.update_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertEquals(client.getOffice().getOfficeId(), office.getOfficeId());
Assert.assertEquals(CustomerStatus.CLIENT_HOLD, client.getStatus());
office = client.getOffice();
StaticHibernateUtil.commitTransaction();
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());
Assert.assertEquals(3, auditLogList.get(0).getAuditLogRecords().size());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Loan Officer Assigned")) {
matchValues(auditLogRecord, "mifos", "-");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
matchValues(auditLogRecord, "Active", "On Hold");
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Branch Office Name")) {
matchValues(auditLogRecord, "TestBranchOffice", "customer_office");
}
}
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class AuditBusinessServiceIntegrationTest method testGetAuditLogRecords.
@Test
public void testGetAuditLogRecords() 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("ColumnName_1", "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());
auditLog = getAuditLog(1, (short) 2);
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class CenterStatusChangeIntegrationTest method auditLogingTracksStatusChangeOfCenterFromActiveToInactive.
@Test
public void auditLogingTracksStatusChangeOfCenterFromActiveToInactive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingPendingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_CANCELLED).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingPendingGroup, existingMeeting);
ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
existingPendingGroup = this.customerDao.findGroupBySystemId(existingPendingGroup.getGlobalCustNum());
existingCancelledClient = this.customerDao.findClientBySystemId(existingCancelledClient.getGlobalCustNum());
existingCenter.setUserContext(TestUtils.makeUserWithLocales());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go inactive", new Date(), existingCenter.getPersonnel(), existingCenter);
// exercise test
customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
// verification
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.CENTER, existingCenter.getCustomerId());
assertThat(auditLogList.size(), is(1));
assertThat(auditLogList.get(0).getEntityTypeAsEnum(), is(EntityType.CENTER));
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class PersonActionStrutsTest method testLoadChangeLog.
@SuppressWarnings("unchecked")
@Test
public void testLoadChangeLog() throws Exception {
addActionAndMethod(Methods.get.toString());
addRequestParameter("globalPersonnelNum", "1");
actionPerform();
flowKey = request.getAttribute(Constants.CURRENTFLOWKEY).toString();
// personnel = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
// Changed the PersonnelBO to PersonnelInformationDto as the former is no longer stored in session using
// business key
PersonnelInformationDto personnel = (PersonnelInformationDto) SessionUtils.getAttribute("personnelInformationDto", request);
AuditLog auditLog = new AuditLog(personnel.getPersonnelId().intValue(), EntityType.PERSONNEL.getValue(), "Mifos", new java.sql.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);
setRequestPathInfo("/PersonAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("method", "loadChangeLog");
addRequestParameter("entityType", "Personnel");
addRequestParameter("entityId", personnel.getPersonnelId().toString());
actionPerform();
Assert.assertEquals(1, ((List) request.getSession().getAttribute(AuditConstants.AUDITLOGRECORDS)).size());
verifyForward("viewPersonnelChangeLog");
personnel = null;
}
use of org.mifos.framework.components.audit.business.AuditLog in project head by mifos.
the class AuditBusinessService method getAuditLogRecords.
public List<AuditLogView> getAuditLogRecords(Short entityType, Integer entityId) throws ServiceException {
try {
LegacyAuditDao auditPersistence = ApplicationContextProvider.getBean(LegacyAuditDao.class);
PersonnelBusinessService personnelService = new PersonnelBusinessService();
List<AuditLog> auditLogRecords = auditPersistence.getAuditLogRecords(entityType, entityId);
List<AuditLogView> auditLogViewList = new ArrayList<AuditLogView>();
for (AuditLog auditLog : auditLogRecords) {
for (AuditLogRecord auditLogRecord : auditLog.getAuditLogRecords()) {
AuditLogView auditLogView = new AuditLogView();
auditLogView.setDate(auditLog.getUpdatedDate().toString());
Short userId = auditLog.getUpdatedBy();
PersonnelBO personnel = personnelService.getPersonnel(userId);
auditLogView.setUser(personnel.getUserName());
auditLogView.setField(auditLogRecord.getFieldName());
String encryptedPasswordAuditFieldName = AuditConfiguration.getColumnNameForPropertyName(AuditConstants.PERSONNEL, AuditConstants.Audit_PASSWORD);
if ((null != encryptedPasswordAuditFieldName) && (auditLogRecord.getFieldName().equals(encryptedPasswordAuditFieldName.trim()))) {
auditLogView.setOldValue(AuditConstants.HIDDEN_PASSWORD);
auditLogView.setNewValue(AuditConstants.HIDDEN_PASSWORD);
} else {
auditLogView.setOldValue(auditLogRecord.getOldValue());
auditLogView.setNewValue(auditLogRecord.getNewValue());
}
auditLogViewList.add(auditLogView);
}
}
return auditLogViewList;
} catch (PersistenceException e) {
throw new ServiceException(e);
}
}
Aggregations