Search in sources :

Example 6 with AuditLog

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");
        }
    }
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Example 7 with AuditLog

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);
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Date(java.sql.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with AuditLog

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));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.util.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 9 with AuditLog

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;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditLog(org.mifos.framework.components.audit.business.AuditLog) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with AuditLog

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);
    }
}
Also used : PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLog(org.mifos.framework.components.audit.business.AuditLog) LegacyAuditDao(org.mifos.framework.components.audit.persistence.LegacyAuditDao) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) ServiceException(org.mifos.framework.exceptions.ServiceException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Aggregations

AuditLog (org.mifos.framework.components.audit.business.AuditLog)19 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)17 Test (org.junit.Test)15 AuditTransactionForTests (org.mifos.framework.hibernate.helper.AuditTransactionForTests)9 Date (java.sql.Date)7 HashSet (java.util.HashSet)7 ArrayList (java.util.ArrayList)4 AuditInterceptor (org.mifos.framework.components.audit.util.helpers.AuditInterceptor)4 AuditLogView (org.mifos.framework.components.audit.util.helpers.AuditLogView)3 Date (java.util.Date)2 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)2 CenterBO (org.mifos.customers.center.business.CenterBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 GroupBO (org.mifos.customers.group.business.GroupBO)2 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)2 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)2 CenterBuilder (org.mifos.domain.builders.CenterBuilder)2 ClientBuilder (org.mifos.domain.builders.ClientBuilder)2