Search in sources :

Example 1 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateLoanOfferingForLogging.

@Test
public void testUpdateLoanOfferingForLogging() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.MONTHLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    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, true, 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());
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOANPRODUCT, new Integer(product.getPrdOfferingId().toString()));
    Assert.assertEquals(1, auditLogList.size());
    Assert.assertEquals(EntityType.LOANPRODUCT.getValue(), auditLogList.get(0).getEntityType());
    Assert.assertEquals(15, auditLogList.get(0).getAuditLogRecords().size());
    for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
        if (auditLogRecord.getFieldName().equalsIgnoreCase("Min Loan Amount")) {
            Assert.assertEquals("300.0", auditLogRecord.getOldValue());
            Assert.assertEquals("1000.0", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Description")) {
            Assert.assertEquals("-", auditLogRecord.getOldValue());
            Assert.assertEquals("Loan Product updated", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Applicable For")) {
            Assert.assertEquals("Groups", auditLogRecord.getOldValue());
            Assert.assertEquals("Clients", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Frequency Of Installments")) {
            Assert.assertEquals("Week(s)", auditLogRecord.getOldValue());
            Assert.assertEquals("Month(s)", 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)

Example 2 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.

the class EditStatusActionStrutsTest method updateSuccessForLoan.

@Ignore("Convert to unit test")
public void updateSuccessForLoan() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    //        createInitialObjects();
    createCenterGroupClientHierarchy();
    accountBO = getLoanAccount(client, meeting, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    setRequestPathInfo("/editStatusAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("input", "loan");
    addRequestParameter("accountId", accountBO.getAccountId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward("load_success");
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editStatusAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "loan");
    addRequestParameter("notes", "Test");
    addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
    addRequestParameter("newStatusId", "8");
    addRequestParameter("flagId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward("preview_success");
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/editStatusAction.do");
    addRequestParameter("method", "update");
    addRequestParameter("notes", "Test");
    addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
    addRequestParameter("newStatusId", "8");
    addRequestParameter("flagId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward(ActionForwards.loan_detail_page.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    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("Explanation")) {
            Assert.assertEquals("-", auditLogRecord.getOldValue());
            Assert.assertEquals("Withdraw", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
            Assert.assertEquals("Active in Good Standing", auditLogRecord.getOldValue());
            Assert.assertEquals("Closed- Rescheduled", auditLogRecord.getNewValue());
        }
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Ignore(org.junit.Ignore)

Example 3 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord in project head by mifos.

the class LoanAccountActionStrutsTest method testLoadChangeLog.

@Test
public void testLoadChangeLog() {
    accountBO = getLoanAccount();
    AuditLog auditLog = new AuditLog(accountBO.getAccountId(), EntityType.LOAN.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("/loanAccountAction.do");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("method", "loadChangeLog");
    addRequestParameter("entityType", "Loan");
    addRequestParameter("entityId", accountBO.getAccountId().toString());
    actionPerform();
    Assert.assertEquals(1, ((List) request.getSession().getAttribute(AuditConstants.AUDITLOGRECORDS)).size());
    verifyForward("viewLoanChangeLog");
}
Also used : 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 4 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord 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 5 with AuditLogRecord

use of org.mifos.framework.components.audit.business.AuditLogRecord 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)

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