FINERACT-1724: Fix batch api response code
This commit is contained in:
committed by
Arnold Gálovics
parent
3885104767
commit
3210a09375
@@ -18,7 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.batch.service;
|
package org.apache.fineract.batch.service;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.jayway.jsonpath.JsonPathException;
|
||||||
import io.github.resilience4j.core.functions.Either;
|
import io.github.resilience4j.core.functions.Either;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
@@ -156,6 +159,12 @@ public class BatchApiServiceImpl implements BatchApiService {
|
|||||||
BatchRequest resolvedChildRequest;
|
BatchRequest resolvedChildRequest;
|
||||||
try {
|
try {
|
||||||
resolvedChildRequest = this.resolutionHelper.resoluteRequest(childNode.getRequest(), response);
|
resolvedChildRequest = this.resolutionHelper.resoluteRequest(childNode.getRequest(), response);
|
||||||
|
} catch (JsonPathException jsonPathException) {
|
||||||
|
BatchResponse childResponse = new BatchResponse().setRequestId(childNode.getRequest().getRequestId())
|
||||||
|
.setHeaders(childNode.getRequest().getHeaders()).setStatusCode(BAD_REQUEST.value())
|
||||||
|
.setBody(jsonPathException.getMessage());
|
||||||
|
responseList.add(childResponse);
|
||||||
|
return;
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
throw new BatchExecutionException(childNode.getRequest(), ex, errorHandler.handle(ex));
|
throw new BatchExecutionException(childNode.getRequest(), ex, errorHandler.handle(ex));
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.integrationtests;
|
package org.apache.fineract.integrationtests;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ import org.apache.fineract.integrationtests.common.system.DatatableHelper;
|
|||||||
import org.apache.fineract.integrationtests.useradministration.users.UserHelper;
|
import org.apache.fineract.integrationtests.useradministration.users.UserHelper;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -2148,11 +2150,17 @@ public class BatchApiTest {
|
|||||||
|
|
||||||
LOG.info("Batch Response : {}", new Gson().toJson(responseOfQueryAndUpdateDatatableBatch));
|
LOG.info("Batch Response : {}", new Gson().toJson(responseOfQueryAndUpdateDatatableBatch));
|
||||||
|
|
||||||
final BatchResponse batchQueryAndUpdateResponse = responseOfQueryAndUpdateDatatableBatch.get(0);
|
final BatchResponse queryResponse = responseOfQueryAndUpdateDatatableBatch.get(0);
|
||||||
|
|
||||||
Assertions.assertEquals(2L, batchQueryAndUpdateResponse.getRequestId());
|
Assertions.assertEquals(1L, queryResponse.getRequestId());
|
||||||
Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, batchQueryAndUpdateResponse.getStatusCode(),
|
Assertions.assertEquals(HttpStatus.SC_OK, queryResponse.getStatusCode(), "Verify Status Code 200 for query datatable entry");
|
||||||
|
|
||||||
|
final BatchResponse updateResponse = responseOfQueryAndUpdateDatatableBatch.get(1);
|
||||||
|
|
||||||
|
Assertions.assertEquals(2L, updateResponse.getRequestId());
|
||||||
|
Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, updateResponse.getStatusCode(),
|
||||||
"Verify Status Code 400 for update datatable entry");
|
"Verify Status Code 400 for update datatable entry");
|
||||||
|
MatcherAssert.assertThat(updateResponse.getBody(), containsString("No results for path"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user