Merge pull request #830 from Vishwa1311/MIFOSX-1035
[MIFOSX-1035] Updated Test Cases for Charges
This commit is contained in:
+246
-84
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosplatform.integrationtests;
|
package org.mifosplatform.integrationtests;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -28,91 +29,60 @@ public class ChargesTest {
|
|||||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testChargesForSavings() {
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Specified due date Charge
|
|
||||||
final Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsSpecifiedDueDateJSON());
|
|
||||||
Assert.assertNotNull(specifiedDueDateChargeId);
|
|
||||||
|
|
||||||
HashMap changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
|
||||||
ChargesHelper.getModifyChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
Integer chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, specifiedDueDateChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", specifiedDueDateChargeId, chargeIdAfterDeletion);
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Savings Activation Charge
|
|
||||||
final Integer savingsActivationChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsActivationFeeJSON());
|
|
||||||
Assert.assertNotNull(savingsActivationChargeId);
|
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, savingsActivationChargeId,
|
|
||||||
ChargesHelper.getModifyChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, savingsActivationChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", savingsActivationChargeId, chargeIdAfterDeletion);
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Charge for Withdrawal Fee
|
|
||||||
final Integer withdrawalFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsWithdrawalFeeJSON());
|
|
||||||
Assert.assertNotNull(withdrawalFeeChargeId);
|
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, withdrawalFeeChargeId,
|
|
||||||
ChargesHelper.getModifyWithdrawalFeeChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, withdrawalFeeChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", withdrawalFeeChargeId, chargeIdAfterDeletion);
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Charge for Annual Fee
|
|
||||||
final Integer annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsAnnualFeeJSON());
|
|
||||||
Assert.assertNotNull(annualFeeChargeId);
|
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, annualFeeChargeId, ChargesHelper.getModifyChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, annualFeeChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", annualFeeChargeId, chargeIdAfterDeletion);
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Charge for Monthly Fee
|
|
||||||
final Integer monthlyFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsMonthlyFeeJSON());
|
|
||||||
Assert.assertNotNull(monthlyFeeChargeId);
|
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, monthlyFeeChargeId, ChargesHelper.getModifyChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, monthlyFeeChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", monthlyFeeChargeId, chargeIdAfterDeletion);
|
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Charge for Overdraft Fee
|
|
||||||
final Integer overdraftFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
|
||||||
ChargesHelper.getSavingsOverdraftFeeJSON());
|
|
||||||
Assert.assertNotNull(overdraftFeeChargeId);
|
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdraftFeeChargeId,
|
|
||||||
ChargesHelper.getModifyChargeJSON());
|
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, overdraftFeeChargeId);
|
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", overdraftFeeChargeId, chargeIdAfterDeletion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChargesForLoans() {
|
public void testChargesForLoans() {
|
||||||
|
|
||||||
|
// Retrieving all Charges
|
||||||
|
ArrayList<HashMap> allChargesData = ChargesHelper.getCharges(this.requestSpec, this.responseSpec);
|
||||||
|
Assert.assertNotNull(allChargesData);
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Disbursement Charge
|
// Testing Creation, Updation and Deletion of Disbursement Charge
|
||||||
final Integer disbursementChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
final Integer disbursementChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
ChargesHelper.getLoanDisbursementJSON());
|
ChargesHelper.getLoanDisbursementJSON());
|
||||||
Assert.assertNotNull(disbursementChargeId);
|
Assert.assertNotNull(disbursementChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
HashMap changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId,
|
HashMap changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId,
|
||||||
ChargesHelper.getModifyChargeJSON());
|
ChargesHelper.getModifyChargeJSON());
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
HashMap chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, disbursementChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageAmountJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, disbursementChargeId);
|
||||||
|
|
||||||
|
HashMap chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargePaymentMode");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargePaymentMode"));
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageLoanAmountWithInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, disbursementChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPercentageInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, disbursementChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
if(ChargesHelper.addfeefrequency) {
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, disbursementChargeId, ChargesHelper.getModifyChargeFeeFrequencyAsWeeksJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, disbursementChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("feeFrequency");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("feeFrequency"));
|
||||||
|
}
|
||||||
|
|
||||||
Integer chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, disbursementChargeId);
|
Integer chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, disbursementChargeId);
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", disbursementChargeId, chargeIdAfterDeletion);
|
Assert.assertEquals("Verifying Charge ID after deletion", disbursementChargeId, chargeIdAfterDeletion);
|
||||||
@@ -122,35 +92,227 @@ public class ChargesTest {
|
|||||||
ChargesHelper.getLoanSpecifiedDueDateJSON());
|
ChargesHelper.getLoanSpecifiedDueDateJSON());
|
||||||
Assert.assertNotNull(specifiedDueDateChargeId);
|
Assert.assertNotNull(specifiedDueDateChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
||||||
ChargesHelper.getModifyChargeJSON());
|
ChargesHelper.getModifyChargeJSON());
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageAmountJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargePaymentMode");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargePaymentMode"));
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageLoanAmountWithInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPercentageInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, specifiedDueDateChargeId);
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, specifiedDueDateChargeId);
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", specifiedDueDateChargeId, chargeIdAfterDeletion);
|
Assert.assertEquals("Verifying Charge ID after deletion", specifiedDueDateChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Installment Fee Charge
|
// Testing Creation, Updation and Deletion of Installment Fee Charge
|
||||||
final Integer installmentFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
final Integer installmentFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
ChargesHelper.getLoanInstallmentFeeJSON());
|
ChargesHelper.getLoanInstallmentFeeJSON());
|
||||||
Assert.assertNotNull(installmentFeeChargeId);
|
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId,
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId,
|
||||||
ChargesHelper.getModifyChargeJSON());
|
ChargesHelper.getModifyChargeJSON());
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, installmentFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageAmountJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, installmentFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargePaymentMode");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargePaymentMode"));
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageLoanAmountWithInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, installmentFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPercentageInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, installmentFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
if(ChargesHelper.addfeefrequency) {
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, installmentFeeChargeId, ChargesHelper.getModifyChargeFeeFrequencyAsMonthsJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, installmentFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("feeFrequency");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("feeFrequency"));
|
||||||
|
}
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, installmentFeeChargeId);
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, installmentFeeChargeId);
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", installmentFeeChargeId, chargeIdAfterDeletion);
|
Assert.assertEquals("Verifying Charge ID after deletion", installmentFeeChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
// Testing Creation, Updation and Deletion of Overdue Installment Fee Charge
|
// Testing Creation, Updation and Deletion of Overdue Installment Fee
|
||||||
|
// Charge
|
||||||
final Integer overdueFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
final Integer overdueFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
ChargesHelper.getLoanOverdueFeeJSON());
|
ChargesHelper.getLoanOverdueFeeJSON());
|
||||||
Assert.assertNotNull(overdueFeeChargeId);
|
Assert.assertNotNull(overdueFeeChargeId);
|
||||||
|
|
||||||
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdueFeeChargeId,
|
// Updating Charge Amount
|
||||||
ChargesHelper.getModifyChargeJSON());
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdueFeeChargeId, ChargesHelper.getModifyChargeJSON());
|
||||||
Assert.assertNotNull(changes);
|
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdueFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageAmountJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargePaymentMode");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargePaymentMode"));
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdueFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPecentageLoanAmountWithInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdueFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeAsPercentageInterestJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
|
||||||
|
|
||||||
|
chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, overdueFeeChargeId);
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, overdueFeeChargeId);
|
||||||
Assert.assertEquals("Verifying Charge ID after deletion", overdueFeeChargeId, chargeIdAfterDeletion);
|
Assert.assertEquals("Verifying Charge ID after deletion", overdueFeeChargeId, chargeIdAfterDeletion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChargesForSavings() {
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Specified due date Charge
|
||||||
|
final Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsSpecifiedDueDateJSON());
|
||||||
|
Assert.assertNotNull(specifiedDueDateChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
|
HashMap changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, specifiedDueDateChargeId,
|
||||||
|
ChargesHelper.getModifyChargeJSON());
|
||||||
|
|
||||||
|
HashMap chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
Integer chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, specifiedDueDateChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", specifiedDueDateChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Savings Activation Charge
|
||||||
|
final Integer savingsActivationChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsActivationFeeJSON());
|
||||||
|
Assert.assertNotNull(savingsActivationChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, savingsActivationChargeId,
|
||||||
|
ChargesHelper.getModifyChargeJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, savingsActivationChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, savingsActivationChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", savingsActivationChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Charge for Withdrawal Fee
|
||||||
|
final Integer withdrawalFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsWithdrawalFeeJSON());
|
||||||
|
Assert.assertNotNull(withdrawalFeeChargeId);
|
||||||
|
|
||||||
|
// Updating Charge-Calculation-Type to Withdrawal-Fee
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, withdrawalFeeChargeId,
|
||||||
|
ChargesHelper.getModifyWithdrawalFeeSavingsChargeJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, withdrawalFeeChargeId);
|
||||||
|
|
||||||
|
HashMap chargeChangedData = (HashMap) chargeDataAfterChanges.get("chargeCalculationType");
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeChangedData.get("id"), changes.get("chargeCalculationType"));
|
||||||
|
|
||||||
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, withdrawalFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", withdrawalFeeChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Charge for Annual Fee
|
||||||
|
final Integer annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsAnnualFeeJSON());
|
||||||
|
Assert.assertNotNull(annualFeeChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, annualFeeChargeId, ChargesHelper.getModifyChargeJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, annualFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", annualFeeChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Charge for Monthly Fee
|
||||||
|
final Integer monthlyFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsMonthlyFeeJSON());
|
||||||
|
Assert.assertNotNull(monthlyFeeChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, monthlyFeeChargeId, ChargesHelper.getModifyChargeJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, monthlyFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, monthlyFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", monthlyFeeChargeId, chargeIdAfterDeletion);
|
||||||
|
|
||||||
|
// Testing Creation, Updation and Deletion of Charge for Overdraft Fee
|
||||||
|
final Integer overdraftFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||||
|
ChargesHelper.getSavingsOverdraftFeeJSON());
|
||||||
|
Assert.assertNotNull(overdraftFeeChargeId);
|
||||||
|
|
||||||
|
// Updating Charge Amount
|
||||||
|
changes = ChargesHelper.updateCharges(this.requestSpec, this.responseSpec, overdraftFeeChargeId,
|
||||||
|
ChargesHelper.getModifyChargeJSON());
|
||||||
|
|
||||||
|
chargeDataAfterChanges = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdraftFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge after Modification", chargeDataAfterChanges.get("amount"), changes.get("amount"));
|
||||||
|
|
||||||
|
chargeIdAfterDeletion = ChargesHelper.deleteCharge(this.responseSpec, this.requestSpec, overdraftFeeChargeId);
|
||||||
|
Assert.assertEquals("Verifying Charge ID after deletion", overdraftFeeChargeId, chargeIdAfterDeletion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+95
-8
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosplatform.integrationtests.common.charges;
|
package org.mifosplatform.integrationtests.common.charges;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||||
@@ -9,7 +10,7 @@ import com.google.gson.Gson;
|
|||||||
import com.jayway.restassured.specification.RequestSpecification;
|
import com.jayway.restassured.specification.RequestSpecification;
|
||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
@SuppressWarnings({ "unused", "rawtypes" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class ChargesHelper {
|
public class ChargesHelper {
|
||||||
|
|
||||||
private static final String CHARGES_URL = "/mifosng-provider/api/v1/charges";
|
private static final String CHARGES_URL = "/mifosng-provider/api/v1/charges";
|
||||||
@@ -42,8 +43,8 @@ public class ChargesHelper {
|
|||||||
private static final Integer CHARGE_FEE_FREQUENCY_YEARS = 3;
|
private static final Integer CHARGE_FEE_FREQUENCY_YEARS = 3;
|
||||||
|
|
||||||
private final static boolean active = true;
|
private final static boolean active = true;
|
||||||
private final static boolean penalty = false;
|
private final static boolean penalty = true;
|
||||||
private final static boolean addfeefrequency = true;
|
public final static boolean addfeefrequency = true;
|
||||||
private final static String amount = "100";
|
private final static String amount = "100";
|
||||||
private final static String currencyCode = "USD";
|
private final static String currencyCode = "USD";
|
||||||
public final static String feeOnMonthDay = "04 March";
|
public final static String feeOnMonthDay = "04 March";
|
||||||
@@ -125,6 +126,7 @@ public class ChargesHelper {
|
|||||||
public static String getLoanSpecifiedDueDateJSON() {
|
public static String getLoanSpecifiedDueDateJSON() {
|
||||||
final HashMap<String, Object> map = populateDefaultsForLoan();
|
final HashMap<String, Object> map = populateDefaultsForLoan();
|
||||||
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
|
map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE);
|
||||||
|
map.put("penalty", ChargesHelper.penalty);
|
||||||
String chargesCreateJson = new Gson().toJson(map);
|
String chargesCreateJson = new Gson().toJson(map);
|
||||||
System.out.println(chargesCreateJson);
|
System.out.println(chargesCreateJson);
|
||||||
return chargesCreateJson;
|
return chargesCreateJson;
|
||||||
@@ -133,6 +135,7 @@ public class ChargesHelper {
|
|||||||
public static String getLoanInstallmentFeeJSON() {
|
public static String getLoanInstallmentFeeJSON() {
|
||||||
final HashMap<String, Object> map = populateDefaultsForLoan();
|
final HashMap<String, Object> map = populateDefaultsForLoan();
|
||||||
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
|
map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE);
|
||||||
|
map.put("penalty", ChargesHelper.penalty);
|
||||||
String chargesCreateJson = new Gson().toJson(map);
|
String chargesCreateJson = new Gson().toJson(map);
|
||||||
System.out.println(chargesCreateJson);
|
System.out.println(chargesCreateJson);
|
||||||
return chargesCreateJson;
|
return chargesCreateJson;
|
||||||
@@ -140,7 +143,7 @@ public class ChargesHelper {
|
|||||||
|
|
||||||
public static String getLoanOverdueFeeJSON() {
|
public static String getLoanOverdueFeeJSON() {
|
||||||
final HashMap<String, Object> map = populateDefaultsForLoan();
|
final HashMap<String, Object> map = populateDefaultsForLoan();
|
||||||
map.put("penalty", true);
|
map.put("penalty", ChargesHelper.penalty);
|
||||||
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
|
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
|
||||||
String chargesCreateJson = new Gson().toJson(map);
|
String chargesCreateJson = new Gson().toJson(map);
|
||||||
System.out.println(chargesCreateJson);
|
System.out.println(chargesCreateJson);
|
||||||
@@ -150,7 +153,6 @@ public class ChargesHelper {
|
|||||||
public static HashMap<String, Object> populateDefaultsForLoan() {
|
public static HashMap<String, Object> populateDefaultsForLoan() {
|
||||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("active", ChargesHelper.active);
|
map.put("active", ChargesHelper.active);
|
||||||
map.put("penalty", ChargesHelper.penalty);
|
|
||||||
map.put("amount", ChargesHelper.amount);
|
map.put("amount", ChargesHelper.amount);
|
||||||
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_LOAN);
|
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_LOAN);
|
||||||
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
|
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
|
||||||
@@ -160,7 +162,7 @@ public class ChargesHelper {
|
|||||||
map.put("monthDayFormat", ChargesHelper.monthDayFormat);
|
map.put("monthDayFormat", ChargesHelper.monthDayFormat);
|
||||||
map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6));
|
map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6));
|
||||||
if (ChargesHelper.addfeefrequency) {
|
if (ChargesHelper.addfeefrequency) {
|
||||||
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
|
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS);
|
||||||
map.put("feeInterval", 2);
|
map.put("feeInterval", 2);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@@ -171,6 +173,21 @@ public class ChargesHelper {
|
|||||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
|
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<HashMap> getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
|
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
|
final Integer chargeId) {
|
||||||
|
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
|
final Integer chargeId) {
|
||||||
|
return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||||
|
CommonConstants.RESPONSE_CHANGES);
|
||||||
|
}
|
||||||
|
|
||||||
public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer chargeId, final String request) {
|
final Integer chargeId, final String request) {
|
||||||
return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
|
return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request,
|
||||||
@@ -186,13 +203,13 @@ public class ChargesHelper {
|
|||||||
public static String getModifyChargeJSON() {
|
public static String getModifyChargeJSON() {
|
||||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("locale", CommonConstants.locale);
|
map.put("locale", CommonConstants.locale);
|
||||||
map.put("amount", "200");
|
map.put("amount", "200.0");
|
||||||
String json = new Gson().toJson(map);
|
String json = new Gson().toJson(map);
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getModifyWithdrawalFeeChargeJSON() {
|
public static String getModifyWithdrawalFeeSavingsChargeJSON() {
|
||||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("locale", CommonConstants.locale);
|
map.put("locale", CommonConstants.locale);
|
||||||
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
|
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
|
||||||
@@ -201,4 +218,74 @@ public class ChargesHelper {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeAsPecentageAmountJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
|
||||||
|
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeAsPecentageLoanAmountWithInterestJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
|
||||||
|
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeAsPercentageInterestJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST);
|
||||||
|
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeFeeFrequencyAsDaysJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS);
|
||||||
|
map.put("feeInterval", 2);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeFeeFrequencyAsWeeksJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS);
|
||||||
|
map.put("feeInterval", 2);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeFeeFrequencyAsMonthsJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
|
||||||
|
map.put("feeInterval", 2);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getModifyChargeFeeFrequencyAsYearsJSON() {
|
||||||
|
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("locale", CommonConstants.locale);
|
||||||
|
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS);
|
||||||
|
map.put("feeInterval", 2);
|
||||||
|
String json = new Gson().toJson(map);
|
||||||
|
System.out.println(json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user