[MIFOSX-1012] JUnit Test Cases for Savings Account Transfer
JUnit Test Cases for Savings Account Transfer
This commit is contained in:
+2
-2
@@ -377,7 +377,7 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
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"));
|
||||
HashMap paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
|
||||
final Integer monthlyFeechargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
@@ -390,7 +390,7 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
HashMap savingsChargeForWaive = charges.get(1);
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsChanrge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -416,7 +416,7 @@ public class GroupSavingsIntegrationTest {
|
||||
|
||||
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"));
|
||||
HashMap paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
|
||||
final Integer monthlyFeechargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
@@ -429,7 +429,7 @@ public class GroupSavingsIntegrationTest {
|
||||
|
||||
HashMap savingsChargeForWaive = charges.get(1);
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsChanrge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
}
|
||||
|
||||
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
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.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountTransferTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountTransferTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* JUnit Test Cases for Account Transfer for.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unused", "static-access" })
|
||||
public class SavingsAccountTransfer {
|
||||
|
||||
public static final String MINIMUM_OPENING_BALANCE = "10000.0";
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
public static final String TO_LOAN_ACCOUNT_TYPE = "1";
|
||||
public static final String TO_SAVINGS_ACCOUNT_TYPE = "2";
|
||||
|
||||
private final String LOAN_APPROVAL_DATE = "01 March 2013";
|
||||
private final String LOAN_DISBURSAL_DATE = "01 March 2013";
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
private SavingsAccountTransferTestBuilder savingsAccountTransferTestBuilder;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
Float TRANSFER_AMOUNT = new Float(savingsAccountHelper.ACCOUNT_TRANSFER_AMOUNT);
|
||||
|
||||
@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 testFundTransferToSavingsAccount() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// Creating Loan Account to which Fund to be Transferred.
|
||||
final Integer toClientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(toClientId);
|
||||
|
||||
final Integer toLoanProductID = createLoanProduct();
|
||||
Assert.assertNotNull(toLoanProductID);
|
||||
|
||||
final Integer toLoanID = applyForLoanApplication(toClientId, toLoanProductID);
|
||||
Assert.assertNotNull(toLoanID);
|
||||
|
||||
HashMap toLoanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, toLoanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(toLoanStatusHashMap);
|
||||
|
||||
toLoanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, toLoanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(toLoanStatusHashMap);
|
||||
|
||||
toLoanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, toLoanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(toLoanStatusHashMap);
|
||||
|
||||
// Creating Savings Account to which fund to be Transferred
|
||||
final Integer toClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(toClientID);
|
||||
|
||||
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(toSavingsProductID);
|
||||
|
||||
final Integer toSavingsID = this.savingsAccountHelper.applyForSavingsApplication(toClientID, toSavingsProductID,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(toSavingsProductID);
|
||||
|
||||
HashMap toSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, toSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsPending(toSavingsStatusHashMap);
|
||||
|
||||
toSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(toSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(toSavingsStatusHashMap);
|
||||
|
||||
toSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(toSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap);
|
||||
|
||||
final HashMap toSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(toSavingsID);
|
||||
|
||||
// Creating Savings Account from which the Fund has to be Transferred
|
||||
final Integer fromClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(fromClientID);
|
||||
|
||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(fromSavingsProductID);
|
||||
|
||||
final Integer fromSavingsID = this.savingsAccountHelper.applyForSavingsApplication(fromClientID, fromSavingsProductID,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(fromSavingsID);
|
||||
|
||||
HashMap fromSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, fromSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsPending(fromSavingsStatusHashMap);
|
||||
|
||||
fromSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(fromSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(fromSavingsStatusHashMap);
|
||||
|
||||
fromSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(fromSavingsID);
|
||||
SavingsStatusChecker.verifySavingsIsActive(fromSavingsStatusHashMap);
|
||||
|
||||
final HashMap fromSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(fromSavingsID);
|
||||
|
||||
Float fromSavingsBalance = new Float(MINIMUM_OPENING_BALANCE);
|
||||
Float toSavingsBalance = new Float(MINIMUM_OPENING_BALANCE);
|
||||
|
||||
this.savingsAccountHelper.toSavingsAccountTransfer(fromClientID, fromSavingsID, toClientID, toSavingsID, TO_SAVINGS_ACCOUNT_TYPE);
|
||||
|
||||
fromSavingsBalance -= new Float(savingsAccountHelper.ACCOUNT_TRANSFER_AMOUNT);
|
||||
toSavingsBalance += new Float(savingsAccountHelper.ACCOUNT_TRANSFER_AMOUNT);
|
||||
|
||||
HashMap fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsID);
|
||||
assertEquals("Verifying From Savings Account Balance after Account Transfer", fromSavingsBalance,
|
||||
fromSavingsSummaryAfter.get("accountBalance"));
|
||||
|
||||
HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsID);
|
||||
assertEquals("Verifying To Savings Account Balance after Account Transfer", toSavingsBalance,
|
||||
toSavingsSummaryAfter.get("accountBalance"));
|
||||
|
||||
this.savingsAccountHelper.toSavingsAccountTransfer(fromClientID, fromSavingsID, toClientId, toLoanID, TO_LOAN_ACCOUNT_TYPE);
|
||||
|
||||
fromSavingsBalance -= TRANSFER_AMOUNT;
|
||||
|
||||
fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsID);
|
||||
assertEquals("Verifying From Savings Account Balance after Account Transfer", fromSavingsBalance,
|
||||
fromSavingsSummaryAfter.get("accountBalance"));
|
||||
|
||||
HashMap toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, toLoanID);
|
||||
assertEquals("Verifying To Loan Repayment Amount after Account Transfer", TRANSFER_AMOUNT, toLoanSummaryAfter.get("totalRepayment"));
|
||||
}
|
||||
|
||||
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 Integer createLoanProduct() {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod("1") //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.build();
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
.withPrincipal("15,000.00") //
|
||||
.withLoanTermFrequency("4") //
|
||||
.withLoanTermFrequencyAsMonths() //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentEveryAfter("1") //
|
||||
.withRepaymentFrequencyTypeAsMonths() //
|
||||
.withInterestRatePerPeriod("2") //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
||||
.withExpectedDisbursementDate("10 January 2013") //
|
||||
.withSubmittedOnDate("10 January 2013") //
|
||||
.build(clientID.toString(), loanProductID.toString());
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
}
|
||||
+7
@@ -47,6 +47,13 @@ public class LoanTransactionHelper {
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||
return (ArrayList) response.get("periods");
|
||||
}
|
||||
|
||||
public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&tenantIdentifier=default";
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
|
||||
|
||||
+28
-13
@@ -20,6 +20,7 @@ public class SavingsAccountHelper {
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String SAVINGS_ACCOUNT_URL = "/mifosng-provider/api/v1/savingsaccounts";
|
||||
private static final String ACCOUNT_TRANSFER_URL = "/mifosng-provider/api/v1/accounttransfers";
|
||||
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";
|
||||
@@ -39,16 +40,19 @@ public class SavingsAccountHelper {
|
||||
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 static final String ACCOUNT_TRANSFER_DATE = "01 March 2013";
|
||||
|
||||
public static final String ACCOUNT_TRANSFER_AMOUNT = "3200";
|
||||
|
||||
public SavingsAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public static String getFutureDate(){
|
||||
|
||||
public static String getFutureDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR)+1);
|
||||
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 1);
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
@@ -83,12 +87,14 @@ public class SavingsAccountHelper {
|
||||
|
||||
public HashMap rejectApplication(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- REJECT SAVINGS APPLICATION -------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(REJECT_SAVINGS_COMMAND, savingsID), getRejectedSavingsAsJSON(CREATED_DATE_PLUS_ONE));
|
||||
return performSavingApplicationActions(createSavingsOperationURL(REJECT_SAVINGS_COMMAND, savingsID),
|
||||
getRejectedSavingsAsJSON(CREATED_DATE_PLUS_ONE));
|
||||
}
|
||||
|
||||
public List rejectApplicationWithErrorCode(final Integer savingsId,final String date){
|
||||
|
||||
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);
|
||||
return (List) performSavingActions(createSavingsOperationURL(REJECT_SAVINGS_COMMAND, savingsId), getRejectedSavingsAsJSON(date),
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
}
|
||||
|
||||
public HashMap withdrawApplication(final Integer savingsID) {
|
||||
@@ -107,7 +113,7 @@ public class SavingsAccountHelper {
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON());
|
||||
}
|
||||
|
||||
public Object deleteSavingsApplication(final Integer savingsId,final String jsonAttributeToGetBack) {
|
||||
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);
|
||||
@@ -116,17 +122,16 @@ public class SavingsAccountHelper {
|
||||
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
@@ -177,6 +182,16 @@ public class SavingsAccountHelper {
|
||||
+ chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer toSavingsAccountTransfer(final Integer fromClientId, final Integer fromAccountId, final Integer toClientId, final Integer toAccountId, final String toAccountType) {
|
||||
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------");
|
||||
final String savingsAccountTransferJSON = new SavingsAccountTransferTestBuilder() //
|
||||
.withTransferOnDate(ACCOUNT_TRANSFER_DATE) //
|
||||
.withTransferAmount(ACCOUNT_TRANSFER_AMOUNT) //
|
||||
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), toAccountType);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||
savingsAccountTransferJSON, "savingsId");
|
||||
}
|
||||
|
||||
private String getApproveSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
@@ -187,7 +202,7 @@ public class SavingsAccountHelper {
|
||||
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);
|
||||
@@ -307,7 +322,7 @@ public class SavingsAccountHelper {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public HashMap getSavingsChanrge(final Integer savingsID, final Integer savingsChargeId) {
|
||||
public HashMap getSavingsCharge(final Integer savingsID, final Integer savingsChargeId) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges/" + savingsChargeId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class SavingsAccountTransferTestBuilder {
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String OFFICE_ID = "1";
|
||||
private static final String FROM_ACCOUNT_TYPE_SAVINGS = "2";
|
||||
private static final String TRANSFER_DESCRIPTION = "Transfer";
|
||||
|
||||
private String transferDate = "";
|
||||
private String transferAmount = "";
|
||||
private String fromAccountType = FROM_ACCOUNT_TYPE_SAVINGS;
|
||||
private String officeId = OFFICE_ID;
|
||||
private String transferDescription = TRANSFER_DESCRIPTION;
|
||||
|
||||
public String build(final String fromAccountId, final String fromClientId, final String toAccountId, final String toClientId, final String toAccountType) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", LOCALE);
|
||||
map.put("fromClientId", fromClientId);
|
||||
map.put("fromAccountId", fromAccountId);
|
||||
map.put("fromAccountType", this.fromAccountType);
|
||||
map.put("fromOfficeId", this.officeId);
|
||||
map.put("toClientId", toClientId);
|
||||
map.put("toAccountId", toAccountId);
|
||||
map.put("toAccountType", toAccountType);
|
||||
map.put("toOfficeId", this.officeId);
|
||||
map.put("transferDate", this.transferDate);
|
||||
map.put("transferAmount", this.transferAmount);
|
||||
map.put("transferDescription", this.transferDescription);
|
||||
String savingsApplicationJSON = new Gson().toJson(map);
|
||||
System.out.println(savingsApplicationJSON);
|
||||
return savingsApplicationJSON;
|
||||
}
|
||||
|
||||
public SavingsAccountTransferTestBuilder withTransferOnDate(final String savingsAccountTransferDate) {
|
||||
this.transferDate = savingsAccountTransferDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsAccountTransferTestBuilder withTransferAmount(final String savingsAccountTransferAmount) {
|
||||
this.transferAmount = savingsAccountTransferAmount;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user