diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SurveyIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SurveyIntegrationTest.java index f813b2dd4..e0807eba5 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SurveyIntegrationTest.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SurveyIntegrationTest.java @@ -1,23 +1,14 @@ package org.mifosplatform.integrationtests; +import org.junit.Before; +import org.mifosplatform.integrationtests.common.Utils; +import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper; + 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; -import org.junit.Before; -import org.junit.Test; -import org.mifosplatform.integrationtests.common.ClientHelper; -import org.mifosplatform.integrationtests.common.Utils; -import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder; -import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder; -import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; /** * Client Loan Integration Test for checking Loan Application Repayment @@ -38,75 +29,4 @@ public class SurveyIntegrationTest { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); } - @Test - public void checkClientLoanCreateAndDisburseFlow() { - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer loanProductID = createLoanProduct(); - final Integer loanID = applyForLoanApplication(clientID, loanProductID); - final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); - verifyLoanRepaymentSchedule(loanSchedule); - - } - - 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("12,000.00") // - .withLoanTermFrequency("4") // - .withLoanTermFrequencyAsMonths() // - .withNumberOfRepayments("4") // - .withRepaymentEveryAfter("1") // - .withRepaymentFrequencyTypeAsMonths() // - .withInterestRatePerPeriod("2") // - .withAmortizationTypeAsEqualInstallments() // - .withInterestTypeAsDecliningBalance() // - .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // - .withExpectedDisbursementDate("20 September 2011") // - .withSubmittedOnDate("20 September 2011") // - .build(clientID.toString(), loanProductID.toString()); - return this.loanTransactionHelper.getLoanId(loanApplicationJSON); - } - - private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule) { - System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); - - assertEquals("Checking for Due Date for 1st Month", new ArrayList(Arrays.asList(2011, 10, 20)), - loanSchedule.get(1).get("dueDate")); - assertEquals("Checking for Principal Due for 1st Month", new Float("2911.49"), loanSchedule.get(1).get("principalOriginalDue")); - assertEquals("Checking for Interest Due for 1st Month", new Float("240.00"), loanSchedule.get(1).get("interestOriginalDue")); - - assertEquals("Checking for Due Date for 2nd Month", new ArrayList(Arrays.asList(2011, 11, 20)), - loanSchedule.get(2).get("dueDate")); - assertEquals("Checking for Principal Due for 2nd Month", new Float("2969.71"), loanSchedule.get(2).get("principalDue")); - assertEquals("Checking for Interest Due for 2nd Month", new Float("181.77"), loanSchedule.get(2).get("interestOriginalDue")); - - assertEquals("Checking for Due Date for 3rd Month", new ArrayList(Arrays.asList(2011, 12, 20)), - loanSchedule.get(3).get("dueDate")); - assertEquals("Checking for Principal Due for 3rd Month", new Float("3029.1"), loanSchedule.get(3).get("principalDue")); - assertEquals("Checking for Interest Due for 3rd Month", new Float("122.38"), loanSchedule.get(3).get("interestOriginalDue")); - - assertEquals("Checking for Due Date for 4th Month", new ArrayList(Arrays.asList(2012, 1, 20)), - loanSchedule.get(4).get("dueDate")); - assertEquals("Checking for Principal Due for 4th Month", new Float("3089.7"), loanSchedule.get(4).get("principalDue")); - assertEquals("Checking for Interest Due for 4th Month", new Float("61.79"), loanSchedule.get(4).get("interestOriginalDue")); - } } \ No newline at end of file