From 5d4bbf191e7ec785fa32e6f3444db641a6946bbe Mon Sep 17 00:00:00 2001 From: Priti Date: Sat, 30 Mar 2013 11:08:16 +0530 Subject: [PATCH] Refactoring --- .../java/ClientLoanIntegrationTest.java | 92 +++---- .../LoanWithWaiveInterestAndWriteOff.java | 237 +++++------------- 2 files changed, 97 insertions(+), 232 deletions(-) diff --git a/mifosng-provider/src/integrationTest/java/ClientLoanIntegrationTest.java b/mifosng-provider/src/integrationTest/java/ClientLoanIntegrationTest.java index 9709cd442..1f21d8112 100644 --- a/mifosng-provider/src/integrationTest/java/ClientLoanIntegrationTest.java +++ b/mifosng-provider/src/integrationTest/java/ClientLoanIntegrationTest.java @@ -19,6 +19,9 @@ import com.jayway.restassured.http.ContentType; import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.specification.RequestSpecification; import com.jayway.restassured.specification.ResponseSpecification; +import org.mifosplatform.integrationtests.testbuilder.LoanApplicationTestBuilder; +import org.mifosplatform.integrationtests.testbuilder.LoanProductTestBuilder; +import org.mifosplatform.integrationtests.testbuilder.Utils; /** * Client Loan Integration Test for checking Loan Application Repayment Schedule. @@ -43,12 +46,9 @@ public class ClientLoanIntegrationTest { public void checkClientLoanCreateAndDisburseFlow(){ Integer clientID = createClient(); - System.out.println("------------------------GENERATED CLIENT ID: "+clientID+"---------------------------\n"); checkClientCreatedOnServer(clientID); Integer loanProductID = createLoanProduct(); - System.out.println("-----------------------GENERATED LOAN PRODUCT ID : "+loanProductID+"---------------------------\n"); - applyForLoanApplication(clientID, loanProductID); ArrayList loanSchedule = getLoanRepaymentSchedule(loanProductID); @@ -64,7 +64,7 @@ public class ClientLoanIntegrationTest { private Integer createClient() { System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); - String json = given().spec(requestSpec).body(getTestClientAsJSON()) + String json = given().spec(requestSpec).body(Utils.getTestClientAsJSON("4 March 2009")) .expect().spec(responseSpec) .when().post("/mifosng-provider/api/v1/clients?tenantIdentifier=default") .andReturn().asString(); @@ -81,7 +81,18 @@ public class ClientLoanIntegrationTest { private Integer createLoanProduct() { System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); - String json = given().spec(requestSpec).body(getTestLoanProductAsJSON()) + String loanProductJSON = new LoanProductTestBuilder() + .withPrincipal("12,000.00") + .withNumberOfRepayments("4") + .withRepaymentAfterEvery("1") + .withRepaymentTypeAsMonth() + .withinterestRatePerPeriod("2") + .withInterestRateFrequencyTypeAsMonths() + .withAmortizationTypeAsEqualInstallments() + .withInterestTypeAsDecliningBalance() + .withinterestRatePerPeriod("1") + .build(); + String json = given().spec(requestSpec).body(loanProductJSON) .expect().spec(responseSpec) .when().post("/mifosng-provider/api/v1/loanproducts?tenantIdentifier=default") .andReturn().asString(); @@ -90,7 +101,22 @@ public class ClientLoanIntegrationTest { private void applyForLoanApplication(final Integer clientID, final Integer loanProductID) { System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); - given().spec(requestSpec).body(getLoanApplicationBodyAsJSON(clientID.toString(), loanProductID.toString())) + String loanApplicationJSON = new LoanApplicationTestBuilder() + .withPrincipal("12,000.00") + .withLoanTermFrequency("4") + .withLoanTermFrequencyAsMonths() + .withNumberOfRepayments("4") + .withRepaymentEveryAfter("1") + .withRepaymentFrequencyTypeAsMonths() + .withInterestRatePerPeriod("2") + .withInterestRateFrequencyTypeAsMonths() + .withAmortizationTypeAsEqualInstallments() + .withInterestTypeAsDecliningBalance() + .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() + .withExpectedDisbursementDate("20 September 2011") + .withSubmittedOnDate("20 September 2011") + .Build(clientID.toString(),loanProductID.toString()); + given().spec(requestSpec).body(loanApplicationJSON) .expect().spec(responseSpec) .when().post("/mifosng-provider/api/v1/loans?tenantIdentifier=default"); } @@ -125,61 +151,7 @@ public class ClientLoanIntegrationTest { } - private String getTestClientAsJSON() { - HashMap map = new HashMap(); - map.put("officeId", "1"); - map.put("firstname", randomNameGenerator("Client_FirstName_", 5)); - map.put("lastname", randomNameGenerator("Client_LastName_", 4)); - map.put("externalId", randomIDGenerator("ID_", 7)); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en"); - map.put("joinedDate", "04 March 2009"); - return new Gson().toJson(map); - } - private String getTestLoanProductAsJSON(){ - HashMap map = new HashMap(); - map.put("name", randomNameGenerator("LOAN_PRODUCT_", 6)); - map.put("currencyCode", "INR"); - map.put("locale", "en_GB"); - map.put("digitsAfterDecimal", "2"); - map.put("principal", "12,000.00"); - map.put("numberOfRepayments", "4"); - map.put("repaymentEvery", "1"); - map.put("repaymentFrequencyType", "2"); - map.put("interestRatePerPeriod", "2"); - map.put("interestRateFrequencyType", "2"); - map.put("amortizationType", "1"); - map.put("interestType", "0"); - map.put("interestCalculationPeriodType", "1"); - map.put("inArrearsTolerance", "0"); - map.put("transactionProcessingStrategyId", "1"); - map.put("accountingRule", "1") ; - return new Gson().toJson(map); - } - - private String getLoanApplicationBodyAsJSON(final String clientID,final String productID){ - HashMap map = new HashMap(); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en_GB"); - map.put("clientId", clientID); - map.put("productId", productID); - map.put("principal", "12,000.00"); - map.put("loanTermFrequency", "4"); - map.put("loanTermFrequencyType", "2"); - map.put("numberOfRepayments", "4"); - map.put("repaymentEvery", "1"); - map.put("repaymentFrequencyType", "2"); - map.put("interestRateFrequencyType", "2"); - map.put("interestRatePerPeriod", "2"); - map.put("amortizationType", "1"); - map.put("interestType", "0"); - map.put("interestCalculationPeriodType", "1"); - map.put("transactionProcessingStrategyId", "1"); - map.put("expectedDisbursementDate", "20 September 2011"); - map.put("submittedOnDate", "20 September 2011"); - return new Gson().toJson(map); - } private String getLoanCalculationBodyAsJSON(final String productID){ HashMap map = new HashMap(); diff --git a/mifosng-provider/src/integrationTest/java/LoanWithWaiveInterestAndWriteOff.java b/mifosng-provider/src/integrationTest/java/LoanWithWaiveInterestAndWriteOff.java index b45ee27fe..6db08a5e2 100644 --- a/mifosng-provider/src/integrationTest/java/LoanWithWaiveInterestAndWriteOff.java +++ b/mifosng-provider/src/integrationTest/java/LoanWithWaiveInterestAndWriteOff.java @@ -8,33 +8,43 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.HashMap; -import junit.framework.Assert; import org.junit.Before; import org.junit.Test; -import com.google.gson.Gson; import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.builder.ResponseSpecBuilder; import com.jayway.restassured.http.ContentType; import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.specification.RequestSpecification; import com.jayway.restassured.specification.ResponseSpecification; +import org.mifosplatform.integrationtests.testbuilder.LoanApplicationTestBuilder; import org.mifosplatform.integrationtests.testbuilder.LoanProductTestBuilder; +import org.mifosplatform.integrationtests.testbuilder.LoanStatusChecker; import org.mifosplatform.integrationtests.testbuilder.Utils; /** - * Client Loan Integration Test for checking Loan Disburstment with Waive Interest and Write-Off. + * Client Loan Integration Test for checking Loan Disbursement with Waive Interest and Write-Off. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public class LoanWithWaiveInterestAndWriteOff { ResponseSpecification responseSpec; RequestSpecification requestSpec; - final String PRINCIPAL="4,500.00", + final String + LP_PRINCIPAL = "12,000.00", + LP_REPAYMENTS ="2", + LP_REPAYMENT_PERIOD="6", + LP_INTEREST_RATE="1", + + PRINCIPAL="4,500.00", + LOAN_TERM_FREQUENCY="18", NUMBER_OF_REPAYMENTS="9", REPAYMENT_PERIOD="2", DISBURSEMENT_DATE="30 October 2010", LOAN_APPLICATION_SUBMISSION_DATE="23 September 2010", + EXPECTED_DISBURSAL_DATE="28 October 2010", + RATE_OF_INTEREST_PER_PERIOD="2", + DATE_OF_JOINING = "04 March 2009", INTEREST_VALUE_AMOUNT = "40.00"; @Before @@ -50,7 +60,7 @@ public class LoanWithWaiveInterestAndWriteOff { @Test public void checkClientLoanCreateAndDisburseFlow(){ //CREATE CLIENT - Integer clientID = createClient(); + Integer clientID = createClient(DATE_OF_JOINING); verifyClientCreatedOnServer(clientID); //CREATE LOAN PRODUCT @@ -58,31 +68,30 @@ public class LoanWithWaiveInterestAndWriteOff { //APPLY FOR LOAN Integer loanID = applyForLoanApplication(clientID, loanProductID); HashMap loanStatusHashMap = getStatusOfLoan(loanID); - verifyLoanStatusIsPending(loanStatusHashMap); + + LoanStatusChecker.verifyLoanStatusIsPending(loanStatusHashMap); //APPROVE LOAN loanStatusHashMap = approveLoan("28 September 2010", loanID); - System.out.println("********************HASHMAP **************"+loanStatusHashMap); - verifyLoanIsApproved(loanStatusHashMap); - verifyLoanStatusIsWaitingForDisbursal(loanStatusHashMap); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + LoanStatusChecker.verifyLoanStatusIsWaitingForDisbursal(loanStatusHashMap); //UNDO APPROVAL loanStatusHashMap = undoApproval(loanID); - verifyLoanNeedsApproval(loanStatusHashMap); + LoanStatusChecker.verifyLoanStatusIsPending(loanStatusHashMap); //RE-APPROVE LOAN ON 1 OCTOBER 2010 loanStatusHashMap = approveLoan("1 October 2010", loanID); - verifyLoanIsApproved(loanStatusHashMap); - verifyLoanStatusIsWaitingForDisbursal(loanStatusHashMap); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + LoanStatusChecker.verifyLoanStatusIsWaitingForDisbursal(loanStatusHashMap); //DISBURSE loanStatusHashMap = disburseLoan(loanID); - verifyLoanStatusIsActive(loanStatusHashMap); + System.out.println("DISBURSE "+loanStatusHashMap); + LoanStatusChecker.verifyLoanStatusIsActive(loanStatusHashMap); //PERFORM REPAYMENTS AND CHECK LOAN STATUS - //----------------------------------------- -// verifyRepaymentScheduleEntryFor(1, 4000.0F, 200.0F, loanID); - + verifyRepaymentScheduleEntryFor(1, 4000.0F,loanID); makeRepayment(540.0f, "1 January 2011", loanID); makeRepayment(540.0f, "1 March 2011", loanID); waiveInterest("1 May 2011", loanID); @@ -93,43 +102,22 @@ public class LoanWithWaiveInterestAndWriteOff { makeRepayment(540.0f, "1 November 2011", loanID); waiveInterest("1 January 2012", loanID); makeRepayment(500.0f, "1 January 2012", loanID); - -// verifyRepaymentScheduleEntryFor(7, 1000.0F, 200.0F, loanID); + verifyRepaymentScheduleEntryFor(7,1000.0f,loanID); //WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED - verifyLoanAccountIsClosed(writeOffLoan("1 March 2012", loanID)); + LoanStatusChecker.verifyLoanAccountIsClosed(writeOffLoan("1 March 2012", loanID)); } - private void verifyLoanNeedsApproval(HashMap loanStatusHashMap) { - assertTrue(getStatus(loanStatusHashMap, "pendingApproval")); - } - - private void verifyLoanIsApproved(HashMap loanStatusHashMap) { - assertFalse(getStatus(loanStatusHashMap, "pendingApproval")); - } - - private void verifyLoanStatusIsWaitingForDisbursal(HashMap loanStatusHashMap) { - assertTrue(getStatus(loanStatusHashMap, "waitingForDisbursal")); - } - - private void verifyLoanStatusIsPending(HashMap loanStatusHashMap) { - assertTrue(getStatus(loanStatusHashMap, "pendingApproval")); - } - - private void verifyLoanStatusIsActive(HashMap loanStatusHashMap) { - assertTrue(getStatus(loanStatusHashMap, "active")); - } - - private void verifyRepaymentScheduleEntryFor(int repaymentNumber, float expectedPrincipal, Float expectedInterest, Integer loanID) { + private void verifyRepaymentScheduleEntryFor(int repaymentNumber, float expectedPrincipalOutstanding ,Integer loanID) { ArrayList repaymentPeriods = getLoanRepaymentSchedule(loanID); - assertEquals(repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"), expectedPrincipal); - assertEquals(repaymentPeriods.get(repaymentNumber).get("interestLoanBalanceOutstanding"), expectedInterest); + assertEquals(repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"), expectedPrincipalOutstanding); + } private HashMap writeOffLoan(String transactionDate, Integer loanID){ System.out.println("--------------------LOAN WRITTEN OFF ON "+transactionDate+"-------------------------------\n"); - String json = given().spec(requestSpec).body(getWriteOffBodyAsJSON(transactionDate)) + String json = given().spec(requestSpec).body(Utils.getWriteOffBodyAsJSON(transactionDate)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=writeoff&tenantIdentifier=default") .andReturn().asString(); @@ -139,14 +127,14 @@ public class LoanWithWaiveInterestAndWriteOff { private void waiveInterest(String transactionDate, Integer loanID){ System.out.println("--------------------Waive INTEREST On "+transactionDate+"-------------------------------\n"); - given().spec(requestSpec).body(getWaiveBodyAsJSON(transactionDate)) + given().spec(requestSpec).body(Utils.getWaiveBodyAsJSON(transactionDate, INTEREST_VALUE_AMOUNT)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=waiveinterest&tenantIdentifier=default"); } private void makeRepayment(Float transactionAmount, String transactionDate, Integer loanID){ - System.out.print("------------------------MADE REPAYMENT ON "+transactionDate+"---------------------------------\n"); - given().spec(requestSpec).body(getRepaymentBodyAsJSON(transactionDate,transactionAmount)) + System.out.print("------------------------MADE REPAYMENT ON " + transactionDate + "---------------------------------\n"); + given().spec(requestSpec).body(Utils.getRepaymentBodyAsJSON(transactionDate, transactionAmount)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=repayment&tenantIdentifier=default"); } @@ -161,14 +149,6 @@ public class LoanWithWaiveInterestAndWriteOff { return (ArrayList)repaymentSchedule.get("periods"); } - private boolean getStatus(HashMap loanStatusMap,String nameOfLoanStatusString){ - return (Boolean)loanStatusMap.get(nameOfLoanStatusString); - } - - private void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){ - Assert.assertTrue(getStatus(loanStatusHashMap, "closed")); - } - private HashMap getStatusOfLoan(Integer loanID){ String json= given().spec(requestSpec) .expect().spec(responseSpec).log().ifError() @@ -188,7 +168,7 @@ public class LoanWithWaiveInterestAndWriteOff { } private HashMap disburseLoan(Integer loanID){ System.out.println("-----------------------------------DISBURSE LOAN-----------------------------------------"); - String json = given().spec(requestSpec).body(getDisburseLoanAsJSON()) + String json = given().spec(requestSpec).body(Utils.getDisburseLoanAsJSON(DISBURSEMENT_DATE)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/loans/" + loanID + "?command=disburse&tenantIdentifier=default") .andReturn().asString(); @@ -198,11 +178,10 @@ public class LoanWithWaiveInterestAndWriteOff { private HashMap approveLoan(String approvalDate, Integer loanID){ System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); - String json =given().spec(requestSpec).body(getApproveLoanAsJSON(approvalDate)) + String json =given().spec(requestSpec).body(Utils.getApproveLoanAsJSON(approvalDate)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/loans/"+ loanID +"?command=approve&tenantIdentifier=default") .andReturn().asString(); - System.out.println("**************CHANGES :"+from(json).get("changes")); HashMap response = from(json).get("changes"); return (HashMap)response.get("status"); } @@ -214,9 +193,9 @@ public class LoanWithWaiveInterestAndWriteOff { return JsonPath.with(json).get("base64EncodedAuthenticationKey"); } - private Integer createClient() { + private Integer createClient(String dateOfJoining) { System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); - String json = given().spec(requestSpec).body(getTestClientAsJSON()) + String json = given().spec(requestSpec).body(Utils.getTestClientAsJSON(dateOfJoining)) .expect().spec(responseSpec).log().ifError() .when().post("/mifosng-provider/api/v1/clients?tenantIdentifier=default") .andReturn().asString(); @@ -234,10 +213,15 @@ public class LoanWithWaiveInterestAndWriteOff { private Integer createLoanProduct() { System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); String loanProductJSON = new LoanProductTestBuilder() - .withPrincipal(PRINCIPAL) + .withPrincipal(LP_PRINCIPAL) .withRepaymentTypeAsMonth() - .withRepaymentAfterEvery(REPAYMENT_PERIOD) - .withNumberOfRepayments(NUMBER_OF_REPAYMENTS) + .withRepaymentAfterEvery(LP_REPAYMENT_PERIOD) + .withNumberOfRepayments(LP_REPAYMENTS) + .withRepaymentTypeAsMonth() + .withinterestRatePerPeriod(LP_INTEREST_RATE) + .withInterestRateFrequencyTypeAsMonths() + .withAmortizationTypeAsEqualPrinciplePayment() + .withInterestTypeAsFlat() .build(); String json = given().spec(requestSpec).body(loanProductJSON) .expect().spec(responseSpec).log().ifError() @@ -248,118 +232,27 @@ public class LoanWithWaiveInterestAndWriteOff { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); - String json = given().spec(requestSpec).body(getLoanApplicationBodyAsJSON(clientID.toString(), loanProductID.toString())) - .expect().spec(responseSpec).log().ifError() - .when().post("/mifosng-provider/api/v1/loans?tenantIdentifier=default") - .andReturn().asString(); + String loanApplicationJSON = new LoanApplicationTestBuilder() + .withPrincipal(PRINCIPAL) + .withLoanTermFrequency(LOAN_TERM_FREQUENCY) + .withLoanTermFrequencyAsMonths() + .withNumberOfRepayments(NUMBER_OF_REPAYMENTS) + .withRepaymentEveryAfter(REPAYMENT_PERIOD) + .withRepaymentFrequencyTypeAsMonths() + .withInterestRateFrequencyTypeAsMonths() + .withInterestRatePerPeriod(RATE_OF_INTEREST_PER_PERIOD) + .withInterestTypeAsFlatBalance() + .withAmortizationTypeAsEqualInstallments() + .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() + .withExpectedDisbursementDate(EXPECTED_DISBURSAL_DATE) + .withSubmittedOnDate(LOAN_APPLICATION_SUBMISSION_DATE) + .Build(clientID.toString(), loanProductID.toString()); + String json = given().spec(requestSpec).body(loanApplicationJSON) + .expect().spec(responseSpec).log().ifError() + .when().post("/mifosng-provider/api/v1/loans?tenantIdentifier=default") + .andReturn().asString(); return from(json).get("loanId"); } - - - private String getWriteOffBodyAsJSON(String transactionDate){ - HashMap map = new HashMap(); - map.put("dateFormat","dd MMMM yyyy"); - map.put("locale","en"); - map.put("note", " LOAN WRITE OFF!!!"); - map.put("transactionDate",transactionDate); - return new Gson().toJson(map); - } - private String getWaiveBodyAsJSON(String transactionDate){ - HashMap map = new HashMap(); - map.put("locale","en"); - map.put("dateFormat","dd MMMM yyyy"); - map.put("transactionDate",transactionDate); - map.put("transactionAmount",INTEREST_VALUE_AMOUNT); - map.put("note", " Interest Waived!!!"); - return new Gson().toJson(map); - } - private String getRepaymentBodyAsJSON(String transactionDate,Float transactionAmount){ - HashMap map = new HashMap(); - map.put("locale","en"); - map.put("dateFormat","dd MMMM yyyy"); - map.put("transactionDate",transactionDate); - map.put("transactionAmount",transactionAmount.toString()); - map.put("note", "Repayment Made!!!"); - return new Gson().toJson(map); - } - private String getApproveLoanAsJSON(String approvalDate){ - HashMap map = new HashMap(); - map.put("locale","en"); - map.put("dateFormat","dd MMMM yyyy"); - map.put("approvedOnDate",approvalDate); - map.put("note", "Approval NOTE"); - System.out.println("***************JSON ***"+new Gson().toJson(map)); - return new Gson().toJson(map); - } - - private String getDisburseLoanAsJSON(){ - HashMap map = new HashMap(); - map.put("locale","en"); - map.put("dateFormat","dd MMMM yyyy"); - map.put("actualDisbursementDate",DISBURSEMENT_DATE); - map.put("note", "DISBURSE NOTE"); - return new Gson().toJson(map); - } - - private String getTestClientAsJSON() { - HashMap map = new HashMap(); - map.put("officeId", "1"); - map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5)); - map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4)); - map.put("externalId", Utils.randomIDGenerator("ID_", 7)); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en"); - map.put("joinedDate", "04 March 2009"); - System.out.println("map : "+map); - return new Gson().toJson(map); - } - - - private String getLoanApplicationBodyAsJSON(final String clientID,final String productID){ - HashMap map = new HashMap(); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en_GB"); - map.put("clientId", clientID); - map.put("productId", productID); - map.put("principal", PRINCIPAL); - map.put("loanTermFrequency", "4"); - map.put("loanTermFrequencyType", "2"); - map.put("numberOfRepayments", NUMBER_OF_REPAYMENTS); - map.put("repaymentEvery", REPAYMENT_PERIOD); - map.put("repaymentFrequencyType", "2"); - map.put("interestRateFrequencyType", "2"); - map.put("interestRatePerPeriod", "2"); - map.put("amortizationType", "1"); - map.put("interestType", "1"); - map.put("interestCalculationPeriodType", "1"); - map.put("transactionProcessingStrategyId", "1"); - map.put("expectedDisbursementDate", DISBURSEMENT_DATE); - map.put("submittedOnDate", LOAN_APPLICATION_SUBMISSION_DATE); - return new Gson().toJson(map); - } - - private String getLoanCalculationBodyAsJSON(String productID){ - HashMap map = new HashMap(); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("locale", "en_GB"); - map.put("productId", productID); - map.put("principal", PRINCIPAL); - map.put("loanTermFrequency", "4"); - map.put("loanTermFrequencyType", "2"); - map.put("numberOfRepayments", NUMBER_OF_REPAYMENTS); - map.put("repaymentEvery", REPAYMENT_PERIOD); - map.put("repaymentFrequencyType", "2"); - map.put("interestRateFrequencyType", "2"); - map.put("interestRatePerPeriod", "2"); - map.put("amortizationType", "1"); - map.put("interestType", "1"); - map.put("interestCalculationPeriodType", "1"); - map.put("expectedDisbursementDate", DISBURSEMENT_DATE); - map.put("transactionProcessingStrategyId", "1"); - return new Gson().toJson(map); - } - - }