fix failing integration tests due to enabling optimistic locking on loans

This commit is contained in:
Vishwas Babu A J
2014-12-04 17:26:46 -08:00
parent 09e2d04a6e
commit 2212618256
5 changed files with 49 additions and 50 deletions
@@ -573,7 +573,7 @@ public class AccountingScenarioIntegrationTest {
final String jobName = "Add Accrual Transactions";
try {
this.schedulerJobHelper.excuteJob(jobName);
this.schedulerJobHelper.executeJob(jobName);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -721,7 +721,7 @@ public class AccountingScenarioIntegrationTest {
final String jobName = "Add Periodic Accrual Transactions";
try {
this.schedulerJobHelper.excuteJob(jobName);
this.schedulerJobHelper.executeJob(jobName);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -867,7 +867,7 @@ public class AccountingScenarioIntegrationTest {
runOndate = dateFormat.format(todayDate.getTime());
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate);
float interestPerDay = (totalInterest / totalDaysInPeriod *4) - INTEREST_3_DAYS ;
float interestPerDay = (totalInterest / totalDaysInPeriod * 4) - INTEREST_3_DAYS;
interestPerDay = new Float(numberFormat.format(interestPerDay));
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), interestPerDay, NEXT_FEE_PORTION,
NEXT_PENALTY_PORTION, loanID);
@@ -101,7 +101,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(false, NONE);
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON());
Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -208,7 +208,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(false, NONE);
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, amountPercentage, "1", null);
@@ -264,7 +264,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(false, NONE);
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false));
Integer flatAccTransfer = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -423,7 +423,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(false, NONE);
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false));
Integer flatAccTransfer = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -731,7 +731,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer loanProductID = createLoanProduct(true, NONE);
List<HashMap> tranches = new ArrayList<HashMap>();
List<HashMap> tranches = new ArrayList<>();
tranches.add(createTrancheDetail("1 March 2014", "25000"));
tranches.add(createTrancheDetail("23 April 2014", "20000"));
@@ -773,7 +773,7 @@ public class ClientLoanIntegrationTest {
final Integer savingsId = createSavings(clientID);
List<HashMap> tranches = new ArrayList<HashMap>();
List<HashMap> tranches = new ArrayList<>();
tranches.add(createTrancheDetail("1 March 2014", "25000"));
tranches.add(createTrancheDetail("23 April 2014", "20000"));
@@ -1135,7 +1135,7 @@ public class ClientLoanIntegrationTest {
}
private List<HashMap> copyChargesForUpdate(List<HashMap> charges, Integer deleteWithChargeId, String amount) {
List<HashMap> loanCharges = new ArrayList<HashMap>();
List<HashMap> loanCharges = new ArrayList<>();
for (HashMap charge : charges) {
if (!charge.get("chargeId").equals(deleteWithChargeId)) {
loanCharges.add(copyForUpdate(charge, amount));
@@ -1211,7 +1211,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON());
addCharges(charges, flatDisbursement, "100", null);
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -1387,7 +1387,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer percentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, percentageDisbursementCharge, "1", null);
@@ -1566,7 +1566,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1"));
addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null);
@@ -1753,7 +1753,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON());
addCharges(charges, flatDisbursement, "100", null);
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -1951,7 +1951,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer percentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, percentageDisbursementCharge, "1", null);
@@ -2145,7 +2145,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1"));
addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null);
@@ -2356,7 +2356,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON());
addCharges(charges, flatDisbursement, "100", null);
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -2455,7 +2455,7 @@ public class ClientLoanIntegrationTest {
*/
final String jobName = "Add Accrual Transactions";
try {
this.schedulerJobHelper.excuteJob(jobName);
this.schedulerJobHelper.executeJob(jobName);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -2558,7 +2558,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer percentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, percentageDisbursementCharge, "1", null);
@@ -2661,7 +2661,7 @@ public class ClientLoanIntegrationTest {
final String jobName = "Add Accrual Transactions";
try {
this.schedulerJobHelper.excuteJob(jobName);
this.schedulerJobHelper.executeJob(jobName);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -2764,7 +2764,7 @@ public class ClientLoanIntegrationTest {
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// Add charges with payment mode regular
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1"));
addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null);
@@ -2871,7 +2871,7 @@ public class ClientLoanIntegrationTest {
final String jobName = "Add Accrual Transactions";
try {
this.schedulerJobHelper.excuteJob(jobName);
this.schedulerJobHelper.executeJob(jobName);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -3246,8 +3246,8 @@ public class ClientLoanIntegrationTest {
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, null);
List<HashMap> charges = new ArrayList<HashMap>();
List<HashMap> charges = new ArrayList<>();
Integer installmentCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "10", false));
addCharges(charges, installmentCharge, "10", null);
@@ -3324,7 +3324,6 @@ public class ClientLoanIntegrationTest {
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
}
@Test
public void testLoanScheduleWithInterestRecalculation_WITH_REST_DAILY_INTEREST_COMPOUND_INTEREST_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
@@ -3605,7 +3604,7 @@ public class ClientLoanIntegrationTest {
verifyLoanRepaymentSchedule(loanSchedule, expectedvalues);
String JobName = "Apply penalty to overdue loans";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
expectedvalues = new ArrayList<>();
@@ -125,7 +125,7 @@ public class SchedulerJobsTestResults {
HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
String JobName = "Apply Annual Fee For Savings";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId);
Float chargeAmount = (Float) chargeData.get("amount");
@@ -165,7 +165,7 @@ public class SchedulerJobsTestResults {
String JobName = "Post Interest For Savings";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
Assert.assertNotSame("Verifying the Balance after running Post Interest for Savings Job", summaryBefore.get("accountBalance"),
@@ -225,7 +225,7 @@ public class SchedulerJobsTestResults {
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
String JobName = "Transfer Fee For Loans From Savings";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
@@ -296,7 +296,7 @@ public class SchedulerJobsTestResults {
String JobName = "Apply Holidays To Loans";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
this.responseSpec, loanID);
@@ -347,7 +347,7 @@ public class SchedulerJobsTestResults {
String JobName = "Pay Due Savings Charges";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
@@ -397,7 +397,7 @@ public class SchedulerJobsTestResults {
String JobName = "Update Accounting Running Balances";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final HashMap runningBalanceAfter = this.accountHelper.getAccountingWithRunningBalanceById(accountID.toString());
final Integer INT_BALANCE = new Integer(MINIMUM_OPENING_BALANCE);
@@ -432,7 +432,7 @@ public class SchedulerJobsTestResults {
String JobName = "Update Loan Arrears Ageing";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") + (Float) loanSummaryData.get("interestOverdue");
@@ -487,7 +487,7 @@ public class SchedulerJobsTestResults {
HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
String JobName = "Update Loan Paid In Advance";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
// Retrieving Loan Repayment Schedule after the successful
// completion of
// Update Loan Paid in Advance Scheduler Job
@@ -550,7 +550,7 @@ public class SchedulerJobsTestResults {
HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
String JobName = "Update loan Summary";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment")
- (Float) loanSummaryBefore.get("feeChargesPaid");
HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
@@ -622,7 +622,7 @@ public class SchedulerJobsTestResults {
Assert.assertNotNull(standingInstructionId);
String JobName = "Execute Standing Instruction";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
HashMap fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsId);
Float fromSavingsBalanceAfter = (Float) fromSavingsSummaryAfter.get("accountBalance");
@@ -683,7 +683,7 @@ public class SchedulerJobsTestResults {
this.responseSpec, loanID);
String JobName = "Apply penalty to overdue loans";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
@@ -728,7 +728,7 @@ public class SchedulerJobsTestResults {
Assert.assertFalse(isNPABefore);
// Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId");
String JobName = "Update Non Performing Assets";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
Assert.assertTrue(isNPAAfter);
}
@@ -805,7 +805,7 @@ public class SchedulerJobsTestResults {
Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") - new Float(FixedDepositAccountHelper.depositAmount);
String JobName = "Transfer Interest To Savings";
this.schedulerJobHelper.excuteJob(JobName);
this.schedulerJobHelper.executeJob(JobName);
fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId);
assertEquals("Verifying opening Balance", new Float(FixedDepositAccountHelper.depositAmount),
fixedDepositSummary.get("accountBalance"));
@@ -7,7 +7,6 @@ package org.mifosplatform.integrationtests.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import org.junit.Assert;
@@ -16,7 +15,7 @@ import com.jayway.restassured.builder.ResponseSpecBuilder;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@SuppressWarnings({ "rawtypes", "unchecked" })
public class SchedulerJobHelper {
private final RequestSpecification requestSpec;
@@ -48,9 +47,10 @@ public class SchedulerJobHelper {
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_SCHEDULER_STATUS_URL, "");
return response;
}
public static void updateSchedulerStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String command) {
final String UPDATE_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?command=" + command +"&" + Utils.TENANT_IDENTIFIER;
public static void updateSchedulerStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String command) {
final String UPDATE_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ UPDATING SCHEDULER STATUS -------------------------");
Utils.performServerPost(requestSpec, responseSpec, UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null);
}
@@ -80,12 +80,12 @@ public class SchedulerJobHelper {
}
public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) {
final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build();
final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build();
final String RUN_SCHEDULER_JOB_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?command=executeJob&" + Utils.TENANT_IDENTIFIER;
System.out.println("------------------------ RUN SCHEDULER JOB -------------------------");
Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null);
}
public static String runSchedulerJobAsJSON() {
final HashMap<String, String> map = new HashMap<>();
String runSchedulerJob = new Gson().toJson(map);
@@ -93,7 +93,7 @@ public class SchedulerJobHelper {
return runSchedulerJob;
}
public void excuteJob(String JobName) throws InterruptedException {
public void executeJob(String JobName) throws InterruptedException {
ArrayList<HashMap> allSchedulerJobsData = getAllSchedulerJobs(this.requestSpec, this.responseSpec);
Assert.assertNotNull(allSchedulerJobsData);
@@ -35,7 +35,6 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
@@ -119,8 +118,9 @@ import com.google.gson.JsonPrimitive;
@UniqueConstraint(columnNames = { "external_id" }, name = "loan_externalid_UNIQUE") })
public class Loan extends AbstractPersistable<Long> {
@Version
int version;
/** Disable optimistic locking till batch jobs failures can be fixed **/
// @Version
// int version;
@Column(name = "account_no", length = 20, unique = true, nullable = false)
private String accountNumber;