added savings test cases
This commit is contained in:
+417
@@ -0,0 +1,417 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.charges.ChargesHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Client Savings Integration Test for checking Savings Application.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
public class ClientSavingsIntegrationTest {
|
||||
|
||||
public static final String DEPOSIT_AMOUNT = "2000";
|
||||
public static final String WITHDRAW_AMOUNT = "1000";
|
||||
public static final String WITHDRAW_AMOUNT_ADJUSTED = "500";
|
||||
public static final String MINIMUM_OPENING_BALANCE = "1000.0";
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsAccount() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId);
|
||||
Assert.assertTrue(modifications.containsKey(SavingsApiConstants.submittedOnDateParamName));
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
this.savingsAccountHelper.calculateInterestForSavings(savingsId);
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Assert.assertFalse(summaryBefore.equals(summary));
|
||||
|
||||
final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
|
||||
// verifySavingsInterest(savingsInterest);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsAccount_CLOSE_APPLICATION() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId);
|
||||
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_DELETE_APPLICATION() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
List<HashMap> error1 = (List<HashMap>) savingsAccountHelperValidationError.deleteSavingsApplication(savingsId,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.savingsaccount.delete.not.in.submittedandpendingapproval.state",
|
||||
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.undoApproval(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
this.savingsAccountHelper.deleteSavingsApplication(savingsId, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
|
||||
List<HashMap> error = savingsAccountHelperValidationError.getSavingsCollectionAttribute(savingsId, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.saving.account.id.invalid", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_REJECT_APPLICATION() {
|
||||
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
List<HashMap> error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId,
|
||||
SavingsAccountHelper.CREATED_DATE_PLUS_ONE);
|
||||
assertEquals("validation.msg.savingsaccount.reject.not.in.submittedandpendingapproval.state",
|
||||
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.undoApproval(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.getFutureDate());
|
||||
assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
|
||||
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
|
||||
assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
|
||||
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.rejectApplication(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsRejected(savingsStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsAccount_WITHDRAW_APPLICATION() {
|
||||
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.withdrawApplication(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsWithdrawn(savingsStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccountTransactions() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
List<HashMap> error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "100",
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.account.is.not.active",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "100", SavingsAccountHelper.TRANSACTION_DATE,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.account.is.not.active",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Float balance = new Float(MINIMUM_OPENING_BALANCE);
|
||||
assertEquals("Verifying opening Balance", balance, summary.get("accountBalance"));
|
||||
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
|
||||
balance += new Float(DEPOSIT_AMOUNT);
|
||||
assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
|
||||
|
||||
Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
|
||||
balance -= new Float(WITHDRAW_AMOUNT);
|
||||
assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
|
||||
|
||||
Integer newWithdrawTransactionId = this.savingsAccountHelper.updateSavingsAccountTransaction(savingsId, withdrawTransactionId,
|
||||
WITHDRAW_AMOUNT_ADJUSTED);
|
||||
HashMap newWithdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, newWithdrawTransactionId);
|
||||
balance = balance + new Float(WITHDRAW_AMOUNT) - new Float(WITHDRAW_AMOUNT_ADJUSTED);
|
||||
assertEquals("Verifying adjusted Amount", new Float(WITHDRAW_AMOUNT_ADJUSTED), newWithdrawTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after adjust", balance, newWithdrawTransaction.get("runningBalance"));
|
||||
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals("Verifying Adjusted Balance", balance, summary.get("accountBalance"));
|
||||
withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
|
||||
Assert.assertTrue((Boolean) withdrawTransaction.get("reversed"));
|
||||
|
||||
this.savingsAccountHelper.undoSavingsAccountTransaction(savingsId, newWithdrawTransactionId);
|
||||
newWithdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
|
||||
Assert.assertTrue((Boolean) newWithdrawTransaction.get("reversed"));
|
||||
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
balance += new Float(WITHDRAW_AMOUNT_ADJUSTED);
|
||||
assertEquals("Verifying Balance After Undo Transaction", balance, summary.get("accountBalance"));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
|
||||
SavingsAccountHelper.getFutureDate(), CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.in.the.future", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "5000", SavingsAccountHelper.getFutureDate(),
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.in.the.future", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.withdrawalFromSavingsAccount(savingsId, "5000",
|
||||
SavingsAccountHelper.CREATED_DATE_MINUS_ONE, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.before.activation.date",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
error = (List) savingsAccountHelperValidationError.depositToSavingsAccount(savingsId, "5000",
|
||||
SavingsAccountHelper.CREATED_DATE_MINUS_ONE, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.before.activation.date",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccountCharges() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
final Integer withdrawalChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsWithdrawalFeeJSON());
|
||||
Assert.assertNotNull(withdrawalChargeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, withdrawalChargeId);
|
||||
ArrayList<HashMap> chargesPendingState = this.savingsAccountHelper.getSavingsChanrges(savingsId);
|
||||
Assert.assertEquals(1, chargesPendingState.size());
|
||||
|
||||
Integer savingsChargeId = (Integer) chargesPendingState.get(0).get("id");
|
||||
HashMap chargeChanges = this.savingsAccountHelper.updateCharges(savingsChargeId, savingsId);
|
||||
Assert.assertTrue(chargeChanges.containsKey("amount"));
|
||||
|
||||
Integer deletedChargeId = this.savingsAccountHelper.deleteCharge(savingsChargeId, savingsId);
|
||||
assertEquals(savingsChargeId, deletedChargeId);
|
||||
|
||||
chargesPendingState = this.savingsAccountHelper.getSavingsChanrges(savingsId);
|
||||
Assert.assertTrue(chargesPendingState == null || chargesPendingState.size() == 0);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
final Integer chargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsAnnualFeeJSON());
|
||||
Assert.assertNotNull(chargeId);
|
||||
|
||||
ArrayList<HashMap> charges = this.savingsAccountHelper.getSavingsChanrges(savingsId);
|
||||
Assert.assertTrue(charges == null || charges.size() == 0);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, chargeId);
|
||||
charges = this.savingsAccountHelper.getSavingsChanrges(savingsId);
|
||||
Assert.assertEquals(1, charges.size());
|
||||
|
||||
HashMap savingsChargeForPay = charges.get(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
List dates = (List) savingsChargeForPay.get("dueDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2));
|
||||
|
||||
this.savingsAccountHelper.payCharge((Integer) savingsChargeForPay.get("id"), savingsId,
|
||||
((Float) savingsChargeForPay.get("amount")).toString(), sdf.format(cal.getTime()));
|
||||
HashMap paidCharge = this.savingsAccountHelper.getSavingsChanrge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
|
||||
final Integer monthlyFeechargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsMonthlyFeeJSON());
|
||||
Assert.assertNotNull(monthlyFeechargeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, monthlyFeechargeId);
|
||||
charges = this.savingsAccountHelper.getSavingsChanrges(savingsId);
|
||||
Assert.assertEquals(2, charges.size());
|
||||
|
||||
HashMap savingsChargeForWaive = charges.get(1);
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsChanrge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
/*
|
||||
* private void verifySavingsInterest(final Object savingsInterest) {
|
||||
* System.out.println(
|
||||
* "--------------------VERIFYING THE BALANCE, INTEREST --------------------------"
|
||||
* );
|
||||
*
|
||||
* assertEquals("Verifying Interest Calculation", new Float("238.3399"),
|
||||
* savingsInterest); }
|
||||
*/
|
||||
}
|
||||
+2
-6
@@ -25,8 +25,8 @@ public class ClientHelper {
|
||||
public static String getTestClientAsJSON(final String dateOfJoining) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("officeId", "1");
|
||||
map.put("firstname", randomNameGenerator("Client_FirstName_", 5));
|
||||
map.put("lastname", randomNameGenerator("Client_LastName_", 4));
|
||||
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
|
||||
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
@@ -44,10 +44,6 @@ public class ClientHelper {
|
||||
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
|
||||
public interface CommonConstants {
|
||||
|
||||
public final static String locale = "en";
|
||||
public static final String dateFormat = "dd MMMM yyyy";
|
||||
public static final String RESPONSE_RESOURCE_ID = "resourceId";
|
||||
public static final String RESPONSE_CHANGES = "changes";
|
||||
public static final String RESPONSE_ERROR = "errors";
|
||||
public static final String RESPONSE_ERROR_MESSAGE_CODE = "userMessageGlobalisationCode";
|
||||
}
|
||||
+7
-1
@@ -21,7 +21,9 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Utils {
|
||||
|
||||
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
|
||||
public static final String TENANT_IDENTIFIER = "tenantIdentifier=default";
|
||||
|
||||
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&"+TENANT_IDENTIFIER;
|
||||
|
||||
public static void initializeRESTAssured() {
|
||||
RestAssured.baseURI = "https://localhost";
|
||||
@@ -97,4 +99,8 @@ public class Utils {
|
||||
public static String randomStringGenerator(final String prefix, final int len) {
|
||||
return randomStringGenerator(prefix, len, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package org.mifosplatform.integrationtests.common.charges;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo;
|
||||
import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType;
|
||||
import org.mifosplatform.portfolio.charge.domain.ChargeTimeType;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class ChargesHelper {
|
||||
|
||||
private static final String CHARGES_URL = "/mifosng-provider/api/v1/charges";
|
||||
private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
private final static boolean active = true;
|
||||
private final static String amount = "100";
|
||||
private final static Integer chargeAppliesTo = ChargeAppliesTo.SAVINGS.getValue();
|
||||
private final static Integer chargeCalculationType = ChargeCalculationType.FLAT.getValue();
|
||||
private final static String currencyCode = "USD";
|
||||
public final static String feeOnMonthDay = "04 March";
|
||||
private final static String monthDayFormat = "dd MMM";
|
||||
|
||||
private static String getChargeName(){
|
||||
return Utils.randomNameGenerator("Charge_", 6);
|
||||
}
|
||||
|
||||
public static String getSavingsAnnualFeeJSON() {
|
||||
final HashMap<String, Object> map = populateDefaults();
|
||||
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
|
||||
map.put("chargeTimeType", ChargeTimeType.ANNUAL_FEE.getValue());
|
||||
String chargesCreateJson = new Gson().toJson(map);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static String getSavingsMonthlyFeeJSON() {
|
||||
final HashMap<String, Object> map = populateDefaults();
|
||||
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay);
|
||||
map.put("chargeTimeType", ChargeTimeType.MONTHLY_FEE.getValue());
|
||||
map.put("feeInterval", 2);
|
||||
String chargesCreateJson = new Gson().toJson(map);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static String getSavingsWithdrawalFeeJSON() {
|
||||
final HashMap<String, Object> map = populateDefaults();
|
||||
map.put("chargeTimeType", ChargeTimeType.WITHDRAWAL_FEE.getValue());
|
||||
String chargesCreateJson = new Gson().toJson(map);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Object> populateDefaults(){
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("active", ChargesHelper.active);
|
||||
map.put("amount", ChargesHelper.amount);
|
||||
map.put("chargeAppliesTo", ChargesHelper.chargeAppliesTo);
|
||||
map.put("chargeCalculationType", ChargesHelper.chargeCalculationType);
|
||||
map.put("currencyCode", ChargesHelper.currencyCode);
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("monthDayFormat", ChargesHelper.monthDayFormat);
|
||||
map.put("name", ChargesHelper.getChargeName());
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,final String request) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+3
-3
@@ -3,7 +3,7 @@ package org.mifosplatform.integrationtests.common.loans;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -30,8 +30,8 @@ public class LoanProductTestBuilder {
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_BASED = "3";
|
||||
|
||||
private String nameOfLoanProduct = ClientHelper.randomNameGenerator("LOAN_PRODUCT_", 6);
|
||||
private String shortName = ClientHelper.randomNameGenerator("", 4);
|
||||
private String nameOfLoanProduct = Utils.randomNameGenerator("LOAN_PRODUCT_", 6);
|
||||
private String shortName = Utils.randomNameGenerator("", 4);
|
||||
private String principal = "10000.00";
|
||||
private String numberOfRepayments = "5";
|
||||
private String repaymentFrequency = MONTHS;
|
||||
|
||||
+359
@@ -0,0 +1,359 @@
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class SavingsAccountHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String SAVINGS_ACCOUNT_URL = "/mifosng-provider/api/v1/savingsaccounts";
|
||||
private static final String APPROVE_SAVINGS_COMMAND = "approve";
|
||||
private static final String UNDO_APPROVAL_SAVINGS_COMMAND = "undoApproval";
|
||||
private static final String ACTIVATE_SAVINGS_COMMAND = "activate";
|
||||
private static final String REJECT_SAVINGS_COMMAND = "reject";
|
||||
private static final String WITHDRAWN_BY_CLIENT_SAVINGS_COMMAND = "withdrawnByApplicant";
|
||||
private static final String CALCULATE_INTEREST_SAVINGS_COMMAND = "calculateInterest";
|
||||
private static final String POST_INTEREST_SAVINGS_COMMAND = "postInterest";
|
||||
private static final String CLOSE_SAVINGS_COMMAND = "close";
|
||||
|
||||
private static final String DEPOSIT_SAVINGS_COMMAND = "deposit";
|
||||
private static final String WITHDRAW_SAVINGS_COMMAND = "withdrawal";
|
||||
private static final String MODIFY_TRASACTION_COMMAND = "modify";
|
||||
private static final String UNDO_TRASACTION_COMMAND = "undo";
|
||||
|
||||
public static final String CREATED_DATE = "08 January 2013";
|
||||
public static final String CREATED_DATE_PLUS_ONE = "09 January 2013";
|
||||
public static final String CREATED_DATE_MINUS_ONE = "07 January 2013";
|
||||
public static final String TRANSACTION_DATE = "10 January 2013";
|
||||
public static final String LAST_TRANSACTION_DATE = "11 January 2013";
|
||||
|
||||
public SavingsAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public static String getFutureDate(){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR)+1);
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
public Integer applyForSavingsApplication(final Integer clientID, final Integer savingsProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
||||
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
||||
.withSubmittedOnDate(CREATED_DATE) //
|
||||
.build(clientID.toString(), savingsProductID.toString());
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||
savingsApplicationJSON, "savingsId");
|
||||
}
|
||||
|
||||
public HashMap updateSavingsAccount(final Integer clientID, final Integer savingsProductID, final Integer savingsId) {
|
||||
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
||||
.withSubmittedOnDate(CREATED_DATE_PLUS_ONE) //
|
||||
.build(clientID.toString(), savingsProductID.toString());
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, savingsApplicationJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap approveSavings(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- APPROVING SAVINGS APPLICATION ------------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(APPROVE_SAVINGS_COMMAND, savingsID), getApproveSavingsAsJSON());
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- UNDO APPROVING SAVINGS APPLICATION -------------------------------");
|
||||
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
return performSavingApplicationActions(createSavingsOperationURL(UNDO_APPROVAL_SAVINGS_COMMAND, savingsID), undoBodyJson);
|
||||
}
|
||||
|
||||
public HashMap rejectApplication(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- REJECT SAVINGS APPLICATION -------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(REJECT_SAVINGS_COMMAND, savingsID), getRejectedSavingsAsJSON(CREATED_DATE_PLUS_ONE));
|
||||
}
|
||||
|
||||
public List rejectApplicationWithErrorCode(final Integer savingsId,final String date){
|
||||
System.out.println("--------------------------------- REJECT SAVINGS APPLICATION -------------------------------");
|
||||
return (List)performSavingActions(createSavingsOperationURL(REJECT_SAVINGS_COMMAND, savingsId), getRejectedSavingsAsJSON(date), CommonConstants.RESPONSE_ERROR);
|
||||
}
|
||||
|
||||
public HashMap withdrawApplication(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- Withdraw SAVINGS APPLICATION -------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(WITHDRAWN_BY_CLIENT_SAVINGS_COMMAND, savingsID),
|
||||
getWithdrawnSavingsAsJSON());
|
||||
}
|
||||
|
||||
public HashMap activateSavings(final Integer savingsID) {
|
||||
System.out.println("---------------------------------- ACTIVATING SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(ACTIVATE_SAVINGS_COMMAND, savingsID), getActivatedSavingsAsJSON());
|
||||
}
|
||||
|
||||
public HashMap closeSavingsAccount(final Integer savingsID) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON());
|
||||
}
|
||||
|
||||
public Object deleteSavingsApplication(final Integer savingsId,final String jsonAttributeToGetBack) {
|
||||
System.out.println("---------------------------------- DELETE SAVINGS APPLICATION ----------------------------------");
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public Object depositToSavingsAccount(final Integer savingsID, final String amount, String date, String jsonAttributeToGetback) {
|
||||
System.out.println("--------------------------------- SAVINGS TRANSACTION DEPOSIT --------------------------------");
|
||||
return performSavingActions(createSavingsTransactionURL(DEPOSIT_SAVINGS_COMMAND, savingsID),
|
||||
getSavingsTransactionJSON(amount, date), jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public Object withdrawalFromSavingsAccount(final Integer savingsId, final String amount, String date, String jsonAttributeToGetback) {
|
||||
System.out.println("\n--------------------------------- SAVINGS TRANSACTION WITHDRAWAL --------------------------------");
|
||||
return performSavingActions(createSavingsTransactionURL(WITHDRAW_SAVINGS_COMMAND, savingsId),
|
||||
getSavingsTransactionJSON(amount, date), jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
|
||||
public Integer updateSavingsAccountTransaction(final Integer savingsId, final Integer transactionId, final String amount) {
|
||||
System.out.println("\n--------------------------------- MODIFY SAVINGS TRANSACTION --------------------------------");
|
||||
return (Integer) performSavingActions(createAdjustTransactionURL(MODIFY_TRASACTION_COMMAND, savingsId, transactionId),
|
||||
getSavingsTransactionJSON(amount, LAST_TRANSACTION_DATE), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer undoSavingsAccountTransaction(final Integer savingsId, final Integer transactionId) {
|
||||
System.out.println("\n--------------------------------- UNDO SAVINGS TRANSACTION --------------------------------");
|
||||
return (Integer) performSavingActions(createAdjustTransactionURL(UNDO_TRASACTION_COMMAND, savingsId, transactionId),
|
||||
getSavingsTransactionJSON("0", LAST_TRANSACTION_DATE), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public void calculateInterestForSavings(final Integer savingsId) {
|
||||
System.out.println("--------------------------------- CALCULATING INTEREST FOR SAVINGS --------------------------------");
|
||||
performSavingActions(createSavingsCalculateInterestURL(CALCULATE_INTEREST_SAVINGS_COMMAND, savingsId),
|
||||
getCalculatedInterestForSavingsApplicationAsJSON(), "");
|
||||
}
|
||||
|
||||
public void postInterestForSavings(final Integer savingsId) {
|
||||
System.out.println("--------------------------------- POST INTEREST FOR SAVINGS --------------------------------");
|
||||
performSavingActions(createSavingsCalculateInterestURL(POST_INTEREST_SAVINGS_COMMAND, savingsId),
|
||||
getCalculatedInterestForSavingsApplicationAsJSON(), "");
|
||||
}
|
||||
|
||||
public Integer addChargesForSavings(final Integer savingsId, final Integer chargeId) {
|
||||
System.out.println("--------------------------------- ADD CHARGES FOR SAVINGS --------------------------------");
|
||||
return (Integer) performSavingActions(SAVINGS_ACCOUNT_URL + "/" + savingsId + "/charges?" + Utils.TENANT_IDENTIFIER,
|
||||
getPeriodChargeRequestJSON(chargeId), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer payCharge(final Integer chargeId, final Integer savingsId, String amount, String dueDate) {
|
||||
return (Integer) performSavingActions(createChargesURL("paycharge", savingsId, chargeId), getSavingsPayChargeJSON(amount, dueDate),
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer waiveCharge(final Integer chargeId, final Integer savingsId) {
|
||||
return (Integer) performSavingActions(createChargesURL("waive", savingsId, chargeId), getSavingsWaiveChargeJSON(),
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap updateCharges(final Integer chargeId, final Integer savingsId) {
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "/charges/" + chargeId
|
||||
+ "?" + Utils.TENANT_IDENTIFIER, getModifyChargeJSON(), CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public Integer deleteCharge(final Integer chargeId, final Integer savingsId) {
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "/" + savingsId + "/charges/"
|
||||
+ chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
private String getApproveSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("note", "Approval NOTE");
|
||||
String savingsAccountApproveJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountApproveJson);
|
||||
return savingsAccountApproveJson;
|
||||
}
|
||||
|
||||
private String getRejectedSavingsAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
map.put("note", "Rejected NOTE");
|
||||
String savingsAccountJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountJson);
|
||||
return savingsAccountJson;
|
||||
}
|
||||
|
||||
private String getWithdrawnSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("note", "Rejected NOTE");
|
||||
String savingsAccountJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountJson);
|
||||
return savingsAccountJson;
|
||||
}
|
||||
|
||||
private String getActivatedSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", "10 January 2013");
|
||||
String savingsAccountActivateJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountActivateJson);
|
||||
return savingsAccountActivateJson;
|
||||
}
|
||||
|
||||
private String getSavingsTransactionJSON(final String amount, final String transactionDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionDate", transactionDate);
|
||||
map.put("transactionAmount", amount);
|
||||
String savingsAccountWithdrawalJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountWithdrawalJson);
|
||||
return savingsAccountWithdrawalJson;
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForSavingsApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
String savingsAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountCalculatedInterestJson);
|
||||
return savingsAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getSavingsPayChargeJSON(final String amount, final String dueDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("amount", amount);
|
||||
map.put("dueDate", dueDate);
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String getSavingsWaiveChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String getModifyChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("amount", "50");
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String getCloseAccountJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", LAST_TRANSACTION_DATE);
|
||||
map.put("note", "Close Test");
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String createSavingsOperationURL(final String command, final Integer savingsID) {
|
||||
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createSavingsTransactionURL(final String command, final Integer savingsID) {
|
||||
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createAdjustTransactionURL(final String command, final Integer savingsID, final Integer transactionId) {
|
||||
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions/" + transactionId + "?command=" + command + "&"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createSavingsCalculateInterestURL(final String command, final Integer savingsID) {
|
||||
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createChargesURL(final String command, final Integer savingsID, final Integer chargeId) {
|
||||
return SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges/" + chargeId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
public ArrayList getSavingsCollectionAttribute(final Integer savingsID, final String jSONAttribute) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
final ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, URL, jSONAttribute);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ArrayList getSavingsChanrges(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public HashMap getSavingsChanrge(final Integer savingsID, final Integer savingsChargeId) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges/" + savingsChargeId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public HashMap getSavingsTransaction(final Integer savingsID, final Integer savingsTransactionId) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "/transactions/" + savingsTransactionId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public Object getSavingsInterest(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=summary&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response.get("totalInterestEarned");
|
||||
}
|
||||
|
||||
public HashMap getSavingsSummary(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=summary&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
private HashMap performSavingApplicationActions(final String postURLForSavingsTransaction, final String jsonToBeSent) {
|
||||
HashMap status = null;
|
||||
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForSavingsTransaction, jsonToBeSent,
|
||||
CommonConstants.RESPONSE_CHANGES);
|
||||
if (response != null) {
|
||||
status = (HashMap) response.get("status");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private Object performSavingActions(final String postURLForSavingsTransaction, final String jsonToBeSent,
|
||||
final String jsonAttributeToGetBack) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForSavingsTransaction, jsonToBeSent,
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getPeriodChargeRequestJSON(Integer chargeId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("chargeId", chargeId);
|
||||
map.put("amount", 100);
|
||||
map.put("feeOnMonthDay", "15 January");
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("monthDayFormat", "dd MMMM");
|
||||
|
||||
String json = new Gson().toJson(map);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class SavingsApplicationTestBuilder {
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
|
||||
private String submittedOnDate = "";
|
||||
|
||||
public String build(final String ID, final String savingsProductId) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put(SavingsApiConstants.dateFormatParamName, "dd MMMM yyyy");
|
||||
map.put(SavingsApiConstants.localeParamName, "en_GB");
|
||||
map.put(SavingsApiConstants.clientIdParamName, ID);
|
||||
map.put(SavingsApiConstants.productIdParamName, savingsProductId);
|
||||
map.put(SavingsApiConstants.localeParamName, LOCALE);
|
||||
map.put(SavingsApiConstants.submittedOnDateParamName, this.submittedOnDate);
|
||||
String savingsApplicationJSON = new Gson().toJson(map);
|
||||
System.out.println(savingsApplicationJSON);
|
||||
return savingsApplicationJSON;
|
||||
}
|
||||
|
||||
public SavingsApplicationTestBuilder withSubmittedOnDate(final String savingsApplicationSubmittedDate) {
|
||||
this.submittedOnDate = savingsApplicationSubmittedDate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SavingsProductHelper {
|
||||
|
||||
private static final String SAVINGS_PRODUCT_URL = "/mifosng-provider/api/v1/savingsproducts";
|
||||
private static final String CREATE_SAVINGS_PRODUCT_URL = SAVINGS_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "4";
|
||||
private static final String IN_MULTIPLES_OF = "0";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEKS = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String DAILY = "1";
|
||||
private static final String MONTHLY = "4";
|
||||
private static final String QUARTERLY = "5";
|
||||
private static final String ANNUAL = "7";
|
||||
private static final String INTEREST_CALCULATION_USING_DAILY_BALANCE = "1";
|
||||
private static final String INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE = "2";
|
||||
private static final String DAYS_360 = "360";
|
||||
private static final String DAYS_365 = "365";
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
|
||||
private String nameOfSavingsProduct = Utils.randomNameGenerator("SAVINGS_PRODUCT_", 6);
|
||||
private String shortName = Utils.randomNameGenerator("", 4);
|
||||
private String description = Utils.randomNameGenerator("", 20);
|
||||
private String interestCompoundingPeriodType = "2";
|
||||
private String interestPostingPeriodType = "4";
|
||||
private String interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
private String nominalAnnualInterestRate = "10.0";
|
||||
private String accountingRule = NONE;
|
||||
private String savingsReferenceAccountId = "1";
|
||||
private String transfersInSuspenseAccountId = "4";
|
||||
private String savingsControlAccountId = "4";
|
||||
private String interestOnSavingsAccountId = "3";
|
||||
private String incomeFromFeeAccountId = "2";
|
||||
private String incomeFromPenaltyAccountId = "2";
|
||||
private String minRequiredOpeningBalance = null;
|
||||
private String lockinPeriodFrequency = "0";
|
||||
private String withdrawalFeeForTransfers = "true";
|
||||
private String lockingPeriodFrequencyType = DAYS;
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
||||
map.put("name", this.nameOfSavingsProduct);
|
||||
map.put("shortName", this.shortName);
|
||||
map.put("description", this.description);
|
||||
map.put("currencyCode", this.currencyCode);
|
||||
map.put("interestCalculationDaysInYearType", this.interestCalculationDaysInYearType);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||
map.put("inMultiplesOf", IN_MULTIPLES_OF);
|
||||
map.put("interestCalculationType", this.interestCalculationType);
|
||||
map.put("nominalAnnualInterestRate", this.nominalAnnualInterestRate);
|
||||
map.put("interestCompoundingPeriodType", this.interestCompoundingPeriodType);
|
||||
map.put("interestPostingPeriodType", this.interestPostingPeriodType);
|
||||
map.put("accountingRule", this.accountingRule);
|
||||
map.put("savingsReferenceAccountId", this.savingsReferenceAccountId);
|
||||
map.put("transfersInSuspenseAccountId", this.transfersInSuspenseAccountId);
|
||||
map.put("savingsControlAccountId", this.savingsControlAccountId);
|
||||
map.put("interestOnSavingsAccountId", this.interestOnSavingsAccountId);
|
||||
map.put("incomeFromFeeAccountId", this.incomeFromFeeAccountId);
|
||||
map.put("incomeFromPenaltyAccountId", this.incomeFromPenaltyAccountId);
|
||||
map.put("minRequiredOpeningBalance", this.minRequiredOpeningBalance);
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("withdrawalFeeForTransfers", this.withdrawalFeeForTransfers);
|
||||
|
||||
if (this.accountingRule.equals(CASH_BASED)) {
|
||||
Account[] account_list = { new Account(1, AccountType.ASSET) };
|
||||
withAccountingRuleAsCashBased(account_list);
|
||||
map.putAll(getAccountMappingForCashBased(account_list));
|
||||
}
|
||||
String savingsProductCreateJson = new Gson().toJson(map);
|
||||
System.out.println(savingsProductCreateJson);
|
||||
return savingsProductCreateJson;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withSavingsName(final String savingsName) {
|
||||
this.nameOfSavingsProduct = savingsName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestCompoundingPeriodTypeAsDaily() {
|
||||
this.interestCompoundingPeriodType = DAILY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withMinimumOpenningBalance(String minBalance) {
|
||||
this.minRequiredOpeningBalance = minBalance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestCompoundingPeriodTypeAsMonthly() {
|
||||
this.interestCompoundingPeriodType = MONTHLY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestPostingPeriodTypeAsMonthly() {
|
||||
this.interestPostingPeriodType = MONTHLY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestPostingPeriodTypeAsQuarterly() {
|
||||
this.interestPostingPeriodType = QUARTERLY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestPostingPeriodTypeAsAnnual() {
|
||||
this.interestPostingPeriodType = ANNUAL;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestCalculationPeriodTypeAsDailyBalance() {
|
||||
this.interestCalculationType = INTEREST_CALCULATION_USING_DAILY_BALANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestCalculationPeriodTypeAsAverageDailyBalance() {
|
||||
this.interestCalculationType = INTEREST_CALCULATION_USING_AVERAGE_DAILY_BALANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withAccountingRuleAsNone() {
|
||||
this.accountingRule = NONE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withAccountingRuleAsCashBased(final Account[] account_list) {
|
||||
this.accountingRule = CASH_BASED;
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased(final Account[] accountList) {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsReferenceAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.LIABILITY)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("savingsControlAccountId", ID);
|
||||
map.put("transfersInSuspenseAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("interestOnSavingsAccountId", ID);
|
||||
}
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Integer createSavingsProduct(final String savingsProductJSON, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_SAVINGS_PRODUCT_URL, savingsProductJSON, "resourceId");
|
||||
}
|
||||
|
||||
public static void verifySavingsProductCreatedOnServer(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer generatedProductID) {
|
||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||
final String GET_SAVINGS_PRODUCT_URL = SAVINGS_PRODUCT_URL + "/" + generatedProductID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseSavingsProductID = Utils.performServerGet(requestSpec, responseSpec, GET_SAVINGS_PRODUCT_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE Savings Product", generatedProductID, responseSavingsProductID);
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SavingsStatusChecker {
|
||||
|
||||
private static final String SAVINGS_ACCOUNT_URL = "/mifosng-provider/api/v1/savingsaccounts";
|
||||
|
||||
public static void verifySavingsIsApproved(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS APPROVED ------------------------------------");
|
||||
assertTrue("ERROR IN APPROVING SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "approved"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsIsPending(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------");
|
||||
assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE", getStatus(savingsStatusHashMap, "submittedAndPendingApproval"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsIsActive(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------");
|
||||
assertTrue("ERROR IN ACTIVATING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "active"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------");
|
||||
assertTrue("ERROR IN REJECTING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "rejected"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------");
|
||||
assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------");
|
||||
assertTrue("ERROR IN CLOSING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "closed"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifySavingsAccountIsNotActive(final HashMap savingsStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS INACTIVE ------------------------------------");
|
||||
assertTrue(getStatus(savingsStatusHashMap, "active"));
|
||||
System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static HashMap getStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer savingsID) {
|
||||
final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
|
||||
}
|
||||
|
||||
private static boolean getStatus(final HashMap savingsStatusMap, final String nameOfSavingsStatusString) {
|
||||
return (Boolean) savingsStatusMap.get(nameOfSavingsStatusString);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user