[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.http.ContentType;
import com.jayway.restassured.specification.RequestSpecification; import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification; import com.jayway.restassured.specification.ResponseSpecification;
import org.mifosplatform.integrationtests.common.LoanApplicationTestBuilder; import org.mifosplatform.integrationtests.common.*;
import org.mifosplatform.integrationtests.common.LoanProductTestBuilder;
import org.mifosplatform.integrationtests.common.LoanTransactionHelper;
import org.mifosplatform.integrationtests.common.Utils;
/** /**
* Client Loan Integration Test for checking Loan Application Repayment Schedule. * Client Loan Integration Test for checking Loan Application Repayment Schedule.
@@ -41,8 +38,8 @@ public class ClientLoanIntegrationTest {
@Test @Test
public void checkClientLoanCreateAndDisburseFlow(){ public void checkClientLoanCreateAndDisburseFlow(){
Integer clientID = Utils.createClient(requestSpec, responseSpec); Integer clientID = ClientBuilder.createClient(requestSpec, responseSpec);
Utils.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID); ClientBuilder.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
Integer loanProductID = createLoanProduct(); Integer loanProductID = createLoanProduct();
Integer loanID= applyForLoanApplication(clientID, loanProductID); Integer loanID= applyForLoanApplication(clientID, loanProductID);
@@ -55,8 +55,8 @@ public class LoanWithWaiveInterestAndWriteOff {
@Test @Test
public void checkClientLoanCreateAndDisburseFlow(){ public void checkClientLoanCreateAndDisburseFlow(){
//CREATE CLIENT //CREATE CLIENT
Integer clientID = Utils.createClient(requestSpec, responseSpec, DATE_OF_JOINING); Integer clientID = ClientBuilder.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
Utils.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID); ClientBuilder.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
//CREATE LOAN PRODUCT //CREATE LOAN PRODUCT
Integer loanProductID = createLoanProduct(); Integer loanProductID = createLoanProduct();
@@ -26,7 +26,7 @@ public class LoanProductTestBuilder {
private static final String ACCRUAL_BASED ="3"; 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 principal = "10000.00";
private String numberOfRepayments = "0"; private String numberOfRepayments = "0";
private String repaymentFrequency = WEEK; private String repaymentFrequency = WEEK;
@@ -63,16 +63,16 @@ public class LoanProductTestBuilder {
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public LoanProductTestBuilder withLoanName(String loanName){ public LoanProductTestBuilder withLoanName(final String loanName){
this.nameOfLoanProduct=loanName; this.nameOfLoanProduct=loanName;
return this; return this;
} }
public LoanProductTestBuilder withPrincipal(String principal){ public LoanProductTestBuilder withPrincipal(final String principal){
this.principal = principal; this.principal = principal;
return this; return this;
} }
public LoanProductTestBuilder withNumberOfRepayments(String numberOfRepayment){ public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment){
this.numberOfRepayments = numberOfRepayment; this.numberOfRepayments = numberOfRepayment;
return this; return this;
} }
@@ -93,7 +93,7 @@ public class LoanProductTestBuilder {
return this; return this;
} }
public LoanProductTestBuilder withRepaymentAfterEvery(String repaymentAfterEvery){ public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery){
this.repaymentPeriod=repaymentAfterEvery; this.repaymentPeriod=repaymentAfterEvery;
return this; return this;
} }
@@ -108,7 +108,7 @@ public class LoanProductTestBuilder {
return this; return this;
} }
public LoanProductTestBuilder withinterestRatePerPeriod(String interestRatePerPeriod) { public LoanProductTestBuilder withinterestRatePerPeriod(final String interestRatePerPeriod) {
this.interestRatePerPeriod=interestRatePerPeriod; this.interestRatePerPeriod=interestRatePerPeriod;
return this; return this;
} }
@@ -143,7 +143,7 @@ public class LoanProductTestBuilder {
return this; return this;
} }
public LoanProductTestBuilder withInArrearsTolerance (String amountCanBeWaved){ public LoanProductTestBuilder withInArrearsTolerance (final String amountCanBeWaved){
this.inArrearsTolerance = amountCanBeWaved; this.inArrearsTolerance = amountCanBeWaved;
return this; return this;
} }
@@ -1,9 +1,13 @@
package org.mifosplatform.integrationtests.common; package org.mifosplatform.integrationtests.common;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import junit.framework.Assert; import junit.framework.Assert;
import java.util.HashMap; 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.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@@ -36,4 +40,9 @@ public class LoanStatusChecker {
public static void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){ public static void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){
Assert.assertTrue(getStatus(loanStatusHashMap, "closed")); 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");
}
} }