Search in sources :

Example 11 with AuditLogRecord

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);
}
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 12 with AuditLogRecord

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

Example 13 with AuditLogRecord

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

Example 14 with AuditLogRecord

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;
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) LoanBO(org.mifos.accounts.loan.business.LoanBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.util.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Example 15 with AuditLogRecord

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");
        }
    }
}
Also used : BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) List(java.util.List) ArrayList(java.util.ArrayList) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Aggregations

AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)18 AuditLog (org.mifos.framework.components.audit.business.AuditLog)17 Test (org.junit.Test)13 HashSet (java.util.HashSet)8 Date (java.sql.Date)7 AuditTransactionForTests (org.mifos.framework.hibernate.helper.AuditTransactionForTests)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 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)2 LegacyAuditDao (org.mifos.framework.components.audit.persistence.LegacyAuditDao)2 ServiceException (org.mifos.framework.exceptions.ServiceException)2 DateTimeService (org.mifos.framework.util.DateTimeService)2 Date (java.util.Date)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 Ignore (org.junit.Ignore)1