use of org.mifos.framework.hibernate.helper.AuditTransactionForTests 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());
}
}
}
use of org.mifos.framework.hibernate.helper.AuditTransactionForTests 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));
}
use of org.mifos.framework.hibernate.helper.AuditTransactionForTests 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");
}
}
}
use of org.mifos.framework.hibernate.helper.AuditTransactionForTests 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));
}
use of org.mifos.framework.hibernate.helper.AuditTransactionForTests 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;
}
Aggregations