fixed integration tests in BatchApiTest
This commit is contained in:
+19
-7
@@ -11,6 +11,8 @@ import org.mifosplatform.batch.domain.BatchResponse;
|
|||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.mifosplatform.integrationtests.common.BatchHelper;
|
import org.mifosplatform.integrationtests.common.BatchHelper;
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
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.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@@ -178,11 +180,25 @@ public class BatchApiTest {
|
|||||||
@Test
|
@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
|
//Create a createClient Request
|
||||||
final BatchRequest br1 = BatchHelper.createClientRequest(4718L, "");
|
final BatchRequest br1 = BatchHelper.createClientRequest(4718L, "");
|
||||||
|
|
||||||
//Create a ApplyLoan Request
|
//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<>();
|
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||||
|
|
||||||
@@ -198,11 +214,7 @@ public class BatchApiTest {
|
|||||||
final JsonElement clientId = new FromJsonHelper().parse(response.get(0).getBody())
|
final JsonElement clientId = new FromJsonHelper().parse(response.get(0).getBody())
|
||||||
.getAsJsonObject().get("clientId");
|
.getAsJsonObject().get("clientId");
|
||||||
|
|
||||||
//Get the loanId parameter from applyLoan Response
|
Assert.assertEquals("Loan Successfully applied to client " + clientId.getAsString(),
|
||||||
final JsonElement loanId = new FromJsonHelper().parse(response.get(1).getBody())
|
200L, (long) response.get(1).getStatusCode());
|
||||||
.getAsJsonObject().get("loanId");
|
|
||||||
|
|
||||||
Assert.assertEquals("Loan Successfully applied to client " + clientId.getAsString() +
|
|
||||||
" with loanId: " + loanId.getAsString(), 200L, (long) response.get(1).getStatusCode());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-2
@@ -166,7 +166,8 @@ public class BatchHelper {
|
|||||||
* @param reference
|
* @param reference
|
||||||
* @return BatchRequest
|
* @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();
|
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
|
//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\"," +
|
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," +
|
"\"loanTermFrequencyType\": 2, \"loanType\": \"individual\", \"numberOfRepayments\": 10," +
|
||||||
"\"repaymentEvery\": 1, \"repaymentFrequencyType\": 2, \"interestRatePerPeriod\": 10," +
|
"\"repaymentEvery\": 1, \"repaymentFrequencyType\": 2, \"interestRatePerPeriod\": 10," +
|
||||||
"\"amortizationType\": 1, \"interestType\": 0, \"interestCalculationPeriodType\": 1," +
|
"\"amortizationType\": 1, \"interestType\": 0, \"interestCalculationPeriodType\": 1," +
|
||||||
|
|||||||
Reference in New Issue
Block a user