From fc0bb3897dad7f45bd33c79a65a54adcf0b741fa Mon Sep 17 00:00:00 2001 From: rishy Date: Tue, 24 Jun 2014 23:27:08 +0530 Subject: [PATCH] fixed integration tests in BatchApiTest --- .../integrationtests/BatchApiTest.java | 28 +++++++++++++------ .../integrationtests/common/BatchHelper.java | 5 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/BatchApiTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/BatchApiTest.java index 857a44476..40a31b022 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/BatchApiTest.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/BatchApiTest.java @@ -11,6 +11,8 @@ import org.mifosplatform.batch.domain.BatchResponse; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.integrationtests.common.BatchHelper; import org.mifosplatform.integrationtests.common.Utils; +import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder; +import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -176,13 +178,27 @@ public class BatchApiTest { * @see org.mifosplatform.batch.command.internal.ApplyLoanCommandStrategy */ @Test - public void shouldReturnOkStatusForApplyLoanCommand(){ + public void shouldReturnOkStatusForApplyLoanCommand(){ + + final String loanProductJSON = new LoanProductTestBuilder() // + .withPrincipal("10000000.00") // + .withNumberOfRepayments("24") // + .withRepaymentAfterEvery("1") // + .withRepaymentTypeAsMonth() // + .withinterestRatePerPeriod("2") // + .withInterestRateFrequencyTypeAsMonths() // + .withAmortizationTypeAsEqualPrincipalPayment() // + .withInterestTypeAsDecliningBalance() // + .currencyDetails("0", "100").build(null); + + Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec) + .getLoanProductId(loanProductJSON); //Create a createClient Request final BatchRequest br1 = BatchHelper.createClientRequest(4718L, ""); //Create a ApplyLoan Request - final BatchRequest br2 = BatchHelper.applyLoanRequest(4719L, 4718L); + final BatchRequest br2 = BatchHelper.applyLoanRequest(4719L, 4718L, productId); final List batchRequests = new ArrayList<>(); @@ -198,11 +214,7 @@ public class BatchApiTest { final JsonElement clientId = new FromJsonHelper().parse(response.get(0).getBody()) .getAsJsonObject().get("clientId"); - //Get the loanId parameter from applyLoan Response - final JsonElement loanId = new FromJsonHelper().parse(response.get(1).getBody()) - .getAsJsonObject().get("loanId"); - - Assert.assertEquals("Loan Successfully applied to client " + clientId.getAsString() + - " with loanId: " + loanId.getAsString(), 200L, (long) response.get(1).getStatusCode()); + Assert.assertEquals("Loan Successfully applied to client " + clientId.getAsString(), + 200L, (long) response.get(1).getStatusCode()); } } \ No newline at end of file diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/BatchHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/BatchHelper.java index 471d0c200..f58e12ce6 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/BatchHelper.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/BatchHelper.java @@ -166,7 +166,8 @@ public class BatchHelper { * @param reference * @return BatchRequest */ - public static BatchRequest applyLoanRequest(final Long requestId, final Long reference) { + public static BatchRequest applyLoanRequest(final Long requestId, final Long reference, + final Integer productId) { final BatchRequest br = new BatchRequest(); @@ -177,7 +178,7 @@ public class BatchHelper { //NOTE: Set the value productId according to your db else will result in a '404' response final String body = "{\"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en_GB\", \"clientId\": \"$.clientId\"," + - "\"productId\": 26, \"principal\": \"10,000.00\", \"loanTermFrequency\": 12," + + "\"productId\": "+productId+", \"principal\": \"10,000.00\", \"loanTermFrequency\": 12," + "\"loanTermFrequencyType\": 2, \"loanType\": \"individual\", \"numberOfRepayments\": 10," + "\"repaymentEvery\": 1, \"repaymentFrequencyType\": 2, \"interestRatePerPeriod\": 10," + "\"amortizationType\": 1, \"interestType\": 0, \"interestCalculationPeriodType\": 1," +