FINERACT-2346: Refractor, Minor Sonar fixes and remove some deprecated code

This commit is contained in:
Aman-Mittal
2025-12-01 19:11:59 +01:00
committed by Adam Saghy
parent 73d8659390
commit 00e9ac8320
17 changed files with 83 additions and 123 deletions
@@ -24,6 +24,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.common.ContentTypes.APPLICATION_JSON;
import static com.github.tomakehurst.wiremock.common.ContentTypes.AUTHORIZATION;
import static com.github.tomakehurst.wiremock.common.ContentTypes.CONTENT_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -66,9 +69,8 @@ class FineractFeignClientIntegrationTest {
@Test
void testJsonEncoding() {
wireMockServer
.stubFor(post(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
.withBody("{\"id\":1,\"message\":\"success\",\"timestamp\":\"2024-01-15T10:30:00\"}")));
wireMockServer.stubFor(post(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":1,\"message\":\"success\",\"timestamp\":\"2024-01-15T10:30:00\"}")));
TestApi client = config.createClient(TestApi.class);
TestRequest request = new TestRequest();
@@ -85,9 +87,8 @@ class FineractFeignClientIntegrationTest {
@Test
void testJsonDecoding() {
wireMockServer
.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
.withBody("{\"id\":42,\"message\":\"decoded-message\",\"timestamp\":\"2024-12-25T18:45:30\"}")));
wireMockServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":42,\"message\":\"decoded-message\",\"timestamp\":\"2024-12-25T18:45:30\"}")));
TestApi client = config.createClient(TestApi.class);
TestResponse response = client.getTest();
@@ -101,7 +102,7 @@ class FineractFeignClientIntegrationTest {
@Test
void testJava8DateTimeSerialization() {
wireMockServer.stubFor(post(urlEqualTo("/test")).withRequestBody(containing("2024-06-30"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":99,\"message\":\"date-test\",\"timestamp\":\"2024-06-30T12:00:00\"}")));
TestApi client = config.createClient(TestApi.class);
@@ -131,7 +132,7 @@ class FineractFeignClientIntegrationTest {
@Test
void testErrorDecoderWithServerError() {
wireMockServer.stubFor(
get(urlEqualTo("/error")).willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json").withBody(
get(urlEqualTo("/error")).willReturn(aResponse().withStatus(500).withHeader(CONTENT_TYPE, APPLICATION_JSON).withBody(
"{\"developerMessage\":\"Internal server error occurred\",\"httpStatusCode\":\"500\",\"defaultUserMessage\":\"Server Error\"}")));
TestApi client = config.createClient(TestApi.class);
@@ -144,9 +145,8 @@ class FineractFeignClientIntegrationTest {
FineractFeignClientConfig ttlConfig = FineractFeignClientConfig.builder().baseUrl(baseUrl).credentials("testuser", "testpass")
.connectionTimeToLive(5, TimeUnit.MINUTES).build();
wireMockServer
.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
.withBody("{\"id\":1,\"message\":\"ttl-test\",\"timestamp\":\"2024-01-01T00:00:00\"}")));
wireMockServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":1,\"message\":\"ttl-test\",\"timestamp\":\"2024-01-01T00:00:00\"}")));
TestApi client = ttlConfig.createClient(TestApi.class);
TestResponse response = client.getTest();
@@ -157,8 +157,8 @@ class FineractFeignClientIntegrationTest {
@Test
void testBasicAuthentication() {
wireMockServer.stubFor(get(urlEqualTo("/test")).withHeader("Authorization", equalTo("Basic dGVzdHVzZXI6dGVzdHBhc3M="))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
wireMockServer.stubFor(get(urlEqualTo("/test")).withHeader(AUTHORIZATION, equalTo("Basic dGVzdHVzZXI6dGVzdHBhc3M="))
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":1,\"message\":\"authenticated\",\"timestamp\":\"2024-01-01T00:00:00\"}")));
TestApi client = config.createClient(TestApi.class);
@@ -170,9 +170,8 @@ class FineractFeignClientIntegrationTest {
@Test
void testNullValueHandling() {
wireMockServer
.stubFor(post(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
.withBody("{\"id\":1,\"message\":null,\"timestamp\":\"2024-01-01T00:00:00\"}")));
wireMockServer.stubFor(post(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, APPLICATION_JSON)
.withBody("{\"id\":1,\"message\":null,\"timestamp\":\"2024-01-01T00:00:00\"}")));
TestApi client = config.createClient(TestApi.class);
TestRequest request = new TestRequest();
@@ -24,6 +24,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.common.ContentTypes.CONTENT_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
import com.github.tomakehurst.wiremock.WireMockServer;
@@ -75,14 +76,14 @@ class ImagesApiIntegrationTest {
void testRetrieveClientImage() throws IOException {
byte[] imageData = new byte[] { (byte) 0xFF, (byte) 0xD8, (byte) 0xFF, 0x10, 0x11, 0x12 };
wireMockServer.stubFor(get(urlEqualTo("/v1/clients/123/images"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "image/jpeg").withBody(imageData)));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "image/jpeg").withBody(imageData)));
ImagesApi api = config.createClient(ImagesApi.class);
Response response = api.get("clients", 123L, new HashMap<>());
assertThat(response.status()).isEqualTo(200);
assertThat(response.headers()).containsKey("Content-Type");
assertThat(response.headers().get("Content-Type")).contains("image/jpeg");
assertThat(response.headers()).containsKey(CONTENT_TYPE);
assertThat(response.headers().get(CONTENT_TYPE)).contains("image/jpeg");
assertThat(response.body().asInputStream().readAllBytes()).isEqualTo(imageData);
}
@@ -91,7 +92,7 @@ class ImagesApiIntegrationTest {
byte[] resizedImage = new byte[] { (byte) 0xFF, (byte) 0xD8, (byte) 0xFF, 0x20, 0x21 };
wireMockServer.stubFor(get(urlPathEqualTo("/v1/clients/123/images")).withQueryParam("maxWidth", equalTo("100"))
.withQueryParam("maxHeight", equalTo("100"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "image/jpeg").withBody(resizedImage)));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "image/jpeg").withBody(resizedImage)));
ImagesApi api = config.createClient(ImagesApi.class);
Map<String, Object> params = new HashMap<>();
@@ -108,7 +109,7 @@ class ImagesApiIntegrationTest {
void testRetrieveClientImageWithMaxWidthOnly() throws IOException {
byte[] resizedImage = new byte[] { (byte) 0xFF, (byte) 0xD8, (byte) 0xFF, 0x30 };
wireMockServer.stubFor(get(urlPathEqualTo("/v1/clients/123/images")).withQueryParam("maxWidth", equalTo("200"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "image/jpeg").withBody(resizedImage)));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "image/jpeg").withBody(resizedImage)));
ImagesApi api = config.createClient(ImagesApi.class);
Map<String, Object> params = new HashMap<>();
@@ -123,7 +124,7 @@ class ImagesApiIntegrationTest {
@Test
void testDeleteClientImage() {
wireMockServer.stubFor(delete(urlEqualTo("/v1/clients/123/images"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody("{\"resourceId\":123}")));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "application/json").withBody("{\"resourceId\":123}")));
ImagesApi api = config.createClient(ImagesApi.class);
Response response = api.delete("clients", 123L);
@@ -134,7 +135,7 @@ class ImagesApiIntegrationTest {
@Test
void testDeleteStaffImage() {
wireMockServer.stubFor(delete(urlEqualTo("/v1/staff/456/images"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody("{\"resourceId\":456}")));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "application/json").withBody("{\"resourceId\":456}")));
ImagesApi api = config.createClient(ImagesApi.class);
Response response = api.delete("staff", 456L);
@@ -146,13 +147,13 @@ class ImagesApiIntegrationTest {
void testRetrieveImageWithPngFormat() throws IOException {
byte[] pngImage = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A };
wireMockServer.stubFor(get(urlEqualTo("/v1/clients/123/images"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "image/png").withBody(pngImage)));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "image/png").withBody(pngImage)));
ImagesApi api = config.createClient(ImagesApi.class);
Response response = api.get("clients", 123L, new HashMap<>());
assertThat(response.status()).isEqualTo(200);
assertThat(response.headers().get("Content-Type")).contains("image/png");
assertThat(response.headers().get(CONTENT_TYPE)).contains("image/png");
assertThat(response.body().asInputStream().readAllBytes()).isEqualTo(pngImage);
}
@@ -166,7 +167,7 @@ class ImagesApiIntegrationTest {
Long entityId = entityIds[i];
wireMockServer.stubFor(get(urlEqualTo("/v1/" + entityType + "/" + entityId + "/images"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "image/jpeg").withBody(new byte[] { 0x01 })));
.willReturn(aResponse().withStatus(200).withHeader(CONTENT_TYPE, "image/jpeg").withBody(new byte[] { 0x01 })));
}
ImagesApi api = config.createClient(ImagesApi.class);
@@ -57,7 +57,7 @@ public enum GLAccountJsonInputParams {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -116,7 +116,7 @@ public enum GLAccountType {
@Override
public String toString() {
return name().toString();
return name();
}
public boolean isAssetType() {
@@ -64,7 +64,7 @@ public abstract class IdTypeResolver {
}
public static String formatIdType(String idType) {
return idType == null ? null : idType.replaceAll("-", "_").toUpperCase();
return idType == null ? null : idType.replace("-", "_").toUpperCase();
}
public static RuntimeException resolveFailed(String idType, Exception e) {
@@ -54,17 +54,17 @@ public class IdempotencyStoreFilter extends OncePerRequestFilter {
extractIdempotentKeyFromHttpServletRequest(request).ifPresent(idempotentKey -> fineractRequestContextHolder
.setAttribute(SynchronousCommandProcessingService.IDEMPOTENCY_KEY_ATTRIBUTE, idempotentKey, request));
filterChain.doFilter(request, wrapper.getValue() != null ? wrapper.getValue() : response);
filterChain.doFilter(request, wrapper.get() != null ? wrapper.get() : response);
Optional<Long> commandId = helper.getCommandId(request);
boolean isSuccessWithoutStored = commandId.isPresent() && wrapper.getValue() != null && helper.isStoreIdempotencyKey(request)
boolean isSuccessWithoutStored = commandId.isPresent() && wrapper.get() != null && helper.isStoreIdempotencyKey(request)
&& helper.isAllowedContentTypeResponse(response);
if (isSuccessWithoutStored) {
helper.storeCommandResult(response.getStatus(), Optional.ofNullable(wrapper.getValue())
helper.storeCommandResult(response.getStatus(), Optional.ofNullable(wrapper.get())
.map(ContentCachingResponseWrapper::getContentAsByteArray).map(s -> new String(s, StandardCharsets.UTF_8)).orElse(null),
commandId.get());
}
if (wrapper.getValue() != null) {
wrapper.getValue().copyBodyToResponse();
if (wrapper.get() != null) {
wrapper.get().copyBodyToResponse();
}
}
@@ -642,7 +642,7 @@ public class JsonParserHelper {
// http://bugs.sun.com/view_bug.do?bug_id=4510618
final char groupingSeparator = symbols.getGroupingSeparator();
if (groupingSeparator == '\u00a0') {
source = source.replaceAll(" ", Character.toString('\u00a0'));
source = source.replace(" ", Character.toString('\u00a0'));
}
final Number parsedNumber = df.parse(source);
@@ -727,9 +727,8 @@ public class JsonParserHelper {
// http://bugs.sun.com/view_bug.do?bug_id=4510618
final char groupingSeparator = symbols.getGroupingSeparator();
if (groupingSeparator == '\u00a0') {
source = source.replaceAll(" ", Character.toString('\u00a0'));
source = source.replace(" ", Character.toString('\u00a0'));
}
final NumberStyleFormatter numberFormatter = new NumberStyleFormatter();
final Number parsedNumber = numberFormatter.parse(source, clientApplicationLocale);
if (parsedNumber instanceof BigDecimal) {
@@ -41,16 +41,11 @@ public enum LegalForm {
public static LegalForm fromInt(final Integer type) {
LegalForm legalForm = null;
switch (type) {
case 1:
legalForm = LegalForm.PERSON;
break;
case 2:
legalForm = LegalForm.ENTITY;
break;
}
return legalForm;
return switch (type) {
case 1 -> LegalForm.PERSON;
case 2 -> LegalForm.ENTITY;
default -> null;
};
}
public boolean isPerson() {
@@ -207,7 +207,7 @@ public class ImagesApiResource {
@Override
public String toString() {
return name().toString().toLowerCase();
return name().toLowerCase();
}
}
@@ -128,7 +128,7 @@ public class FileSystemContentRepository implements ContentRepository {
*/
private String generateFileParentDirectory(final String entityType, final Long entityId) {
return fineractProperties.getContent().getFilesystem().getRootFolder() + File.separator
+ ThreadLocalContextUtil.getTenant().getName().replaceAll(" ", "").trim() + File.separator + "documents" + File.separator
+ ThreadLocalContextUtil.getTenant().getName().replace(" ", "").trim() + File.separator + "documents" + File.separator
+ entityType + File.separator + entityId + File.separator + ContentRepositoryUtils.generateRandomString();
}
@@ -138,7 +138,7 @@ public class FileSystemContentRepository implements ContentRepository {
*/
private String generateClientImageParentDirectory(final Long resourceId) {
return fineractProperties.getContent().getFilesystem().getRootFolder() + File.separator
+ ThreadLocalContextUtil.getTenant().getName().replaceAll(" ", "").trim() + File.separator + "images" + File.separator
+ ThreadLocalContextUtil.getTenant().getName().replace(" ", "").trim() + File.separator + "images" + File.separator
+ "clients" + File.separator + resourceId;
}
@@ -46,22 +46,18 @@ public class LoanProductPaymentAllocationRuleMerger {
Set<PaymentAllocationTransactionType> existing = new HashSet<>(originalItems.keySet());
Set<PaymentAllocationTransactionType> newSet = new HashSet<>(newItems.keySet());
existing.removeAll(newSet);
if (existing.size() > 0) {
if (!existing.isEmpty()) {
updated = true;
existing.forEach(type -> {
loanProduct.getPaymentAllocationRules().remove(originalItems.get(type));
});
existing.forEach(type -> loanProduct.getPaymentAllocationRules().remove(originalItems.get(type)));
}
// elements to be added
existing = new HashSet<>(originalItems.keySet());
newSet = new HashSet<>(newItems.keySet());
newSet.removeAll(existing);
if (newSet.size() > 0) {
if (!newSet.isEmpty()) {
updated = true;
newSet.forEach(type -> {
loanProduct.getPaymentAllocationRules().add(newItems.get(type));
});
newSet.forEach(type -> loanProduct.getPaymentAllocationRules().add(newItems.get(type)));
}
// elements to be merged
@@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
@@ -90,7 +89,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("health")
@Operation(summary = "Query Interoperation Health Request", description = "")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") })
@ApiResponse(responseCode = "200", description = "OK")
public String health(@Context UriInfo uriInfo) {
return "OK";
}
@@ -100,8 +99,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}")
@Operation(summary = "Query Interoperation Account details", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropAccountData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropAccountData.class)))
public String getAccountDetails(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@Context UriInfo uriInfo) {
InteropAccountData result = interopService.getAccountDetails(accountId);
@@ -115,8 +113,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/transactions")
@Operation(summary = "Query transactions by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionsData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionsData.class)))
public String getAccountTransactions(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@DefaultValue("true") @QueryParam("debit") @Parameter(description = "debit") boolean debit,
@DefaultValue("false") @QueryParam("credit") @Parameter(description = "credit") boolean credit,
@@ -139,8 +136,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/identifiers")
@Operation(summary = "Query Interoperation secondary identifiers by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifiersResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifiersResponseData.class)))
public String getAccountIdentifiers(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@Context UriInfo uriInfo) {
InteropIdentifiersResponseData result = interopService.getAccountIdentifiers(accountId);
@@ -154,8 +150,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Query Interoperation Account by secondary identifier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String getAccountByIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Context UriInfo uriInfo) {
InteropIdentifierAccountResponseData result = interopService.getAccountByIdentifier(idType, idValue, null);
@@ -169,8 +164,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Query Interoperation Account by secondary identifier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String getAccountByIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType, @Context UriInfo uriInfo) {
@@ -186,8 +180,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String registerAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Parameter(hidden = true) String identifierJson,
@Context UriInfo uriInfo) {
@@ -207,8 +200,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String registerAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType,
@@ -229,8 +221,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}")
@Operation(summary = "Allow Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String deleteAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().deleteAccountIdentifier(idType, idValue, null).build();
@@ -248,8 +239,7 @@ public class InteropApiResource {
@Path("parties/{idType}/{idValue}/{subIdOrType}")
@Operation(summary = "Allow Interoperation Identifier registration", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropIdentifierRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropIdentifierAccountResponseData.class)))
public String deleteAccountIdentifier(@PathParam("idType") @Parameter(description = "idType") InteropIdentifierType idType,
@PathParam("idValue") @Parameter(description = "idValue") String idValue,
@PathParam("subIdOrType") @Parameter(description = "subIdOrType") String subIdOrType, @Context UriInfo uriInfo) {
@@ -267,8 +257,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/requests/{requestCode}")
@Operation(summary = "Query Interoperation Transaction Request", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class)))
public String getTransactionRequest(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("requestCode") @Parameter(description = "requestCode") String requestCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_REQUEST);
@@ -285,8 +274,7 @@ public class InteropApiResource {
@Path("requests")
@Operation(summary = "Allow Interoperation Transaction Request", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropTransactionRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransactionRequestResponseData.class)))
public String createTransactionRequest(@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().createTransactionRequest().withJson(quotesJson).build();
@@ -302,8 +290,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/quotes/{quoteCode}")
@Operation(summary = "Query Interoperation Quote", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class)))
public String getQuote(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("quoteCode") @Parameter(description = "quoteCode") String quoteCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_QUOTE);
@@ -320,8 +307,7 @@ public class InteropApiResource {
@Path("quotes")
@Operation(summary = "Calculate Interoperation Quote", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropQuoteRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropQuoteResponseData.class)))
public String createQuote(@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
CommandWrapper commandRequest = new InteropWrapperBuilder().createQuotes().withJson(quotesJson).build();
@@ -336,8 +322,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{transactionCode}/transfers/{transferCode}")
@Operation(summary = "Query Interoperation Transfer", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class)))
public String getTransfer(@PathParam("transactionCode") @Parameter(description = "transactionCode") String transactionCode,
@PathParam("transferCode") @Parameter(description = "transferCode") String transferCode, @Context UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(ENTITY_NAME_QUOTE);
@@ -354,8 +339,7 @@ public class InteropApiResource {
@Path("transfers")
@Operation(summary = "Prepare Interoperation Transfer", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = InteropTransferRequestData.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropTransferResponseData.class)))
public String performTransfer(@QueryParam("action") @Parameter(description = "action") String action,
@Parameter(hidden = true) String quotesJson, @Context UriInfo uriInfo) {
@@ -383,8 +367,7 @@ public class InteropApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Path("accounts/{accountId}/kyc")
@Operation(summary = "Query KYC by Account Id", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropKycResponseData.class))) })
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InteropKycResponseData.class)))
public String getClientKyc(@PathParam("accountId") @Parameter(description = "accountId") String accountId, @Context UriInfo uriInfo) {
InteropKycResponseData result = interopService.getKyc(accountId);
ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
@@ -458,17 +458,15 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
private void checkClientOrGroupActive(final Loan loan) {
final Client client = loan.client();
if (client != null) {
if (client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
if (client != null && client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
final Group group = loan.group();
if (group != null) {
if (group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
if (group != null && group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
}
@Override
@@ -46,7 +46,7 @@ public class GenerateAdhocClientScheduleTasklet implements Tasklet {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
final Collection<AdHocData> adhocs = adHocReadPlatformService.retrieveAllActiveAdHocQuery();
if (adhocs.size() > 0) {
if (!adhocs.isEmpty()) {
adhocs.forEach(adhoc -> {
boolean run = true;
LocalDate next = null;
@@ -83,7 +83,7 @@ public class GenerateAdhocClientScheduleTasklet implements Tasklet {
final StringBuilder insertSqlBuilder = new StringBuilder(900);
insertSqlBuilder.append("INSERT INTO ").append(adhoc.getTableName()).append("(").append(adhoc.getTableFields())
.append(") ").append(adhoc.getQuery());
if (insertSqlBuilder.length() > 0) {
if (!insertSqlBuilder.isEmpty()) {
final int result = jdbcTemplate.update(insertSqlBuilder.toString());
log.debug("{}: Records affected by generateClientSchedule: {}", ThreadLocalContextUtil.getTenant().getName(),
result);
@@ -150,7 +150,7 @@ public class InterestIncentivesFields {
public void validateIncentiveData(final DataValidatorBuilder baseDataValidator) {
switch (attributeName()) {
case GENDER:
case GENDER, CLIENT_CLASSIFICATION, CLIENT_TYPE:
baseDataValidator.reset().parameter(attributeValueParamName).value(this.attributeValue).longGreaterThanZero();
baseDataValidator.reset().parameter(conditionTypeParamName).value(this.conditionType)
.isOneOfTheseValues(ConditionType.EQUAL.getValue(), ConditionType.NOT_EQUAL.getValue());
@@ -158,17 +158,6 @@ public class InterestIncentivesFields {
case AGE:
baseDataValidator.reset().parameter(attributeValueParamName).value(this.attributeValue).longGreaterThanZero();
break;
case CLIENT_CLASSIFICATION:
baseDataValidator.reset().parameter(attributeValueParamName).value(this.attributeValue).longGreaterThanZero();
baseDataValidator.reset().parameter(conditionTypeParamName).value(this.conditionType)
.isOneOfTheseValues(ConditionType.EQUAL.getValue(), ConditionType.NOT_EQUAL.getValue());
break;
case CLIENT_TYPE:
baseDataValidator.reset().parameter(attributeValueParamName).value(this.attributeValue).longGreaterThanZero();
baseDataValidator.reset().parameter(conditionTypeParamName).value(this.conditionType)
.isOneOfTheseValues(ConditionType.EQUAL.getValue(), ConditionType.NOT_EQUAL.getValue());
break;
default:
break;
}
@@ -51,7 +51,7 @@ public enum InterestIncentiveEntityType {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public Integer getValue() {
@@ -41,25 +41,25 @@ public final class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositIsApproved(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "approved"), "Error in Approving Fixed deposit application");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval"), "FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositIsActive(final HashMap fixedDepositStatusHashMap) {
LOG.info("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "active"), "ERROR IN ACTIVATING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) {
LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "rejected"), "ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) {
@@ -71,13 +71,13 @@ public final class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositAccountIsClosed(final HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "closed"), "ERROR IN CLOSING THE FIXED DEPOSIT APPLICATION");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositAccountIsNotActive(final HashMap fixedDepositStatusHashMap) {
LOG.info("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------");
Assertions.assertFalse(getStatus(fixedDepositStatusHashMap, "active"));
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@@ -90,13 +90,13 @@ public final class FixedDepositAccountStatusChecker {
public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "prematureClosed"), "ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) {
LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------");
assertTrue(getStatus(fixedDepositStatusHashMap, "matured"), "ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT");
LOG.info("{}", fixedDepositStatusHashMap.toString());
LOG.info("{}", fixedDepositStatusHashMap);
}
private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) {