[FINERACT-1678] Set a limit to the request body list size on Inline Loan COB API
This commit is contained in:
+8
@@ -45,6 +45,14 @@ public class InlineLoanCOBHelper extends IntegrationTest {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, EXECUTE_INLINE_COB_API, buildInlineCOBRequest(loanIds));
|
||||
}
|
||||
|
||||
public String executeInlineCOB(List<Long> loanIds, String responseAttribute) {
|
||||
final String EXECUTE_INLINE_COB_API = "/fineract-provider/api/v1/jobs/LOAN_COB/inline";
|
||||
log.info("------------------EXECUTE INLINE COB----------------------");
|
||||
log.info("------------------Loan IDs: {}----------------------", loanIds);
|
||||
return Utils.performServerPost(requestSpec, responseSpec, EXECUTE_INLINE_COB_API, buildInlineCOBRequest(loanIds),
|
||||
responseAttribute);
|
||||
}
|
||||
|
||||
private static String buildInlineCOBRequest(List<Long> loanIds) {
|
||||
final HashMap<String, List<Long>> map = new HashMap<>();
|
||||
map.put("loanIds", loanIds);
|
||||
|
||||
+11
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.integrationtests.inlinecob;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
@@ -31,6 +32,7 @@ import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.LongStream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.batch.domain.BatchRequest;
|
||||
import org.apache.fineract.batch.domain.BatchResponse;
|
||||
@@ -390,6 +392,15 @@ public class InlineLoanCOBTest {
|
||||
Assertions.assertEquals(LocalDate.of(2020, 3, 9), loan.getLastClosedBusinessDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInlineCOBRequestBodyItemLimitValidation() {
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
inlineLoanCOBHelper = new InlineLoanCOBHelper(requestSpec, responseSpec);
|
||||
List<Long> loanIds = LongStream.rangeClosed(1, 1001).boxed().toList();
|
||||
String responseUserMessage = inlineLoanCOBHelper.executeInlineCOB(loanIds, "defaultUserMessage");
|
||||
assertEquals("Size of the loan IDs list cannot be over 1000", responseUserMessage);
|
||||
}
|
||||
|
||||
private void createNewSimpleUserWithoutBypassPermission() {
|
||||
GetOfficesResponse headOffice = OfficeHelper.getHeadOffice(requestSpec, responseSpec);
|
||||
String username = Utils.uniqueRandomStringGenerator("NotificationUser", 4);
|
||||
|
||||
Reference in New Issue
Block a user