Search in sources :

Example 16 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord 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");
        }
    }
}
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 17 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord 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?
        }
    }
}
Also used : AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) MeetingBO(org.mifos.application.meeting.business.MeetingBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.sql.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Money(org.mifos.framework.util.helpers.Money) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) Test(org.junit.Test)

Example 18 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord 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());
        }
    }
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.sql.Date) 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