Search in sources :

Example 1 with AuditLog

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

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

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

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

the class GroupStatusChangeIntegrationTest method auditLogingTracksStatusChangeOfGroupFromActiveToCancelled.

@Test
public void auditLogingTracksStatusChangeOfGroupFromActiveToCancelled() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
    ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
    existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
    existingActiveGroup.setUserContext(TestUtils.makeUserWithLocales());
    CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingActiveGroup.getPersonnel(), existingActiveGroup);
    // exercise test
    customerService.updateGroupStatus(existingActiveGroup, existingActiveGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
    StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
    // verification
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.GROUP, existingActiveGroup.getCustomerId());
    assertThat(auditLogList.size(), is(1));
    assertThat(auditLogList.get(0).getEntityTypeAsEnum(), is(EntityType.GROUP));
}
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) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) AuditLog(org.mifos.framework.components.audit.business.AuditLog) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 5 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)

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