fixed integration tests in BatchApiTest

This commit is contained in:
rishy
2014-06-24 23:28:16 +05:30
parent cb52335e23
commit fc0bb3897d
2 changed files with 23 additions and 10 deletions
@@ -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<BatchRequest> 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());
}
}
@@ -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," +