[Priti/Sailee] Refactoring

This commit is contained in:
Priti
2013-04-02 16:34:00 +05:30
parent a66ef5cfbf
commit be32e0b7eb
4 changed files with 21 additions and 15 deletions
@@ -18,10 +18,7 @@ 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.mifosplatform.integrationtests.common.LoanApplicationTestBuilder;
import org.mifosplatform.integrationtests.common.LoanProductTestBuilder;
import org.mifosplatform.integrationtests.common.LoanTransactionHelper;
import org.mifosplatform.integrationtests.common.Utils;
import org.mifosplatform.integrationtests.common.*;
/**
* Client Loan Integration Test for checking Loan Application Repayment Schedule.
@@ -41,8 +38,8 @@ public class ClientLoanIntegrationTest {
@Test
public void checkClientLoanCreateAndDisburseFlow(){
Integer clientID = Utils.createClient(requestSpec, responseSpec);
Utils.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
Integer clientID = ClientBuilder.createClient(requestSpec, responseSpec);
ClientBuilder.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
Integer loanProductID = createLoanProduct();
Integer loanID= applyForLoanApplication(clientID, loanProductID);
@@ -55,8 +55,8 @@ public class LoanWithWaiveInterestAndWriteOff {
@Test
public void checkClientLoanCreateAndDisburseFlow(){
//CREATE CLIENT
Integer clientID = Utils.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
Utils.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
Integer clientID = ClientBuilder.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
ClientBuilder.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
//CREATE LOAN PRODUCT
Integer loanProductID = createLoanProduct();
@@ -26,7 +26,7 @@ public class LoanProductTestBuilder {
private static final String ACCRUAL_BASED ="3";
private String nameOfLoanProduct = Utils.randomNameGenerator("LOAN_PRODUCT_", 6);
private String nameOfLoanProduct = ClientBuilder.randomNameGenerator("LOAN_PRODUCT_", 6);
private String principal = "10000.00";
private String numberOfRepayments = "0";
private String repaymentFrequency = WEEK;
@@ -63,16 +63,16 @@ public class LoanProductTestBuilder {
return new Gson().toJson(map);
}
public LoanProductTestBuilder withLoanName(String loanName){
public LoanProductTestBuilder withLoanName(final String loanName){
this.nameOfLoanProduct=loanName;
return this;
}
public LoanProductTestBuilder withPrincipal(String principal){
public LoanProductTestBuilder withPrincipal(final String principal){
this.principal = principal;
return this;
}
public LoanProductTestBuilder withNumberOfRepayments(String numberOfRepayment){
public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment){
this.numberOfRepayments = numberOfRepayment;
return this;
}
@@ -93,7 +93,7 @@ public class LoanProductTestBuilder {
return this;
}
public LoanProductTestBuilder withRepaymentAfterEvery(String repaymentAfterEvery){
public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery){
this.repaymentPeriod=repaymentAfterEvery;
return this;
}
@@ -108,7 +108,7 @@ public class LoanProductTestBuilder {
return this;
}
public LoanProductTestBuilder withinterestRatePerPeriod(String interestRatePerPeriod) {
public LoanProductTestBuilder withinterestRatePerPeriod(final String interestRatePerPeriod) {
this.interestRatePerPeriod=interestRatePerPeriod;
return this;
}
@@ -143,7 +143,7 @@ public class LoanProductTestBuilder {
return this;
}
public LoanProductTestBuilder withInArrearsTolerance (String amountCanBeWaved){
public LoanProductTestBuilder withInArrearsTolerance (final String amountCanBeWaved){
this.inArrearsTolerance = amountCanBeWaved;
return this;
}
@@ -1,9 +1,13 @@
package org.mifosplatform.integrationtests.common;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import junit.framework.Assert;
import java.util.HashMap;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.path.json.JsonPath.from;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -36,4 +40,9 @@ public class LoanStatusChecker {
public static void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){
Assert.assertTrue(getStatus(loanStatusHashMap, "closed"));
}
public static HashMap getStatusOfLoan(RequestSpecification requestSpec, ResponseSpecification responseSpec, Integer loanID){
String url = "/mifosng-provider/api/v1/loans/" + loanID + "?tenantIdentifier=default";
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
}
}