diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java index 944f5364c..93db8ce19 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java @@ -20,7 +20,6 @@ package org.apache.fineract.portfolio.paymenttype.api; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -36,20 +35,17 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.UriInfo; -import java.util.Collection; +import java.util.List; import lombok.RequiredArgsConstructor; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; -import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; +import org.apache.fineract.portfolio.paymenttype.data.request.PaymentTypeRequest; import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.springframework.stereotype.Component; @@ -64,26 +60,16 @@ public class PaymentTypeApiResource { private final DefaultToApiJsonSerializer jsonSerializer; private final PaymentTypeReadPlatformService readPlatformService; private final PortfolioCommandSourceWritePlatformService commandWritePlatformService; - private final ApiRequestParameterHelper apiRequestParameterHelper; private final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper; @GET @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Retrieve all Payment Types", description = "Retrieve list of payment types") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.GetPaymentTypesResponse.class)))) }) - public String getAllPaymentTypes(@Context final UriInfo uriInfo, + public List getAllPaymentTypes( @QueryParam("onlyWithCode") @Parameter(description = "onlyWithCode") final boolean onlyWithCode) { - this.securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); - Collection paymentTypes = null; - if (onlyWithCode) { - paymentTypes = this.readPlatformService.retrieveAllPaymentTypesWithCode(); - } else { - paymentTypes = this.readPlatformService.retrieveAllPaymentTypes(); - } - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.jsonSerializer.serialize(settings, paymentTypes, PaymentTypeApiResourceConstants.RESPONSE_DATA_PARAMETERS); + securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); + return onlyWithCode ? readPlatformService.retrieveAllPaymentTypesWithCode() : readPlatformService.retrieveAllPaymentTypes(); } @GET @@ -91,15 +77,11 @@ public class PaymentTypeApiResource { @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Retrieve a Payment Type", description = "Retrieves a payment type") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.GetPaymentTypesPaymentTypeIdResponse.class))) }) - public String retrieveOnePaymentType(@PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId, - @Context final UriInfo uriInfo) { - this.securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); - this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); - final PaymentTypeData paymentTypes = this.readPlatformService.retrieveOne(paymentTypeId); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.jsonSerializer.serialize(settings, paymentTypes, PaymentTypeApiResourceConstants.RESPONSE_DATA_PARAMETERS); + public PaymentTypeData retrieveOnePaymentType( + @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId) { + securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); + paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); + return readPlatformService.retrieveOne(paymentTypeId); } @POST @@ -107,16 +89,16 @@ public class PaymentTypeApiResource { @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Create a Payment Type", description = "Creates a new Payment type\n\n" + "Mandatory Fields: name\n\n" + "Optional Fields: Description, isCashPayment,Position") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PostPaymentTypesRequest.class))) + @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PaymentTypeRequest.class))) @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PostPaymentTypesResponse.class))) }) - public String createPaymentType(@Parameter(hidden = true) final String apiRequestBodyAsJson) { + public CommandProcessingResult createPaymentType(@Parameter(hidden = true) PaymentTypeRequest paymentTypeRequest) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createPaymentType().withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createPaymentType() + .withJson(jsonSerializer.serialize(paymentTypeRequest)).build(); - final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); - - return this.jsonSerializer.serialize(result); + CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); + return result; } @PUT @@ -127,15 +109,15 @@ public class PaymentTypeApiResource { @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdRequest.class))) @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdResponse.class))) }) - public String updatePaymentType(@PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId, + public CommandProcessingResult updatePaymentType( + @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId, @Parameter(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePaymentType(paymentTypeId).withJson(apiRequestBodyAsJson) .build(); - final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); - - return this.jsonSerializer.serialize(result); + final CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); + return result; } @DELETE @@ -145,13 +127,14 @@ public class PaymentTypeApiResource { @Operation(summary = "Delete a Payment Type", description = "Deletes payment type") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.DeletePaymentTypesPaymentTypeIdResponse.class))) }) - public String deleteCode(@PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId) { + public CommandProcessingResult deleteCode( + @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deletePaymentType(paymentTypeId).build(); - final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); + final CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); - return this.jsonSerializer.serialize(result); + return result; } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java index 522c70134..325c4836b 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java @@ -48,46 +48,6 @@ public final class PaymentTypeApiResourceSwagger { public Boolean isSystemDefined; } - @Schema(description = "GetPaymentTypesPaymentTypeIdResponse") - public static final class GetPaymentTypesPaymentTypeIdResponse { - - private GetPaymentTypesPaymentTypeIdResponse() {} - - @Schema(example = "13") - public Long id; - @Schema(example = "cash") - public String name; - @Schema(example = "cash Payment") - public String description; - @Schema(example = "true") - public Boolean isCashPayment; - @Schema(example = "1") - public Integer position; - @Schema(example = "REPAYMENT_REFUND") - public String codeName; - @Schema(example = "false") - public Boolean isSystemDefined; - } - - @Schema(description = "PostPaymentTypesRequest") - public static final class PostPaymentTypesRequest { - - private PostPaymentTypesRequest() {} - - @Schema(example = "cash") - public String name; - @Schema(example = "cash payment type") - public String description; - @Schema(example = "true") - public Boolean isCashPayment; - @Schema(example = "1") - public Integer position; - @Schema(example = "REPAYMENT_REFUND") - public String codeName; - @Schema(example = "false") - public Boolean isSystemDefined; - } - @Schema(description = "PostPaymentTypesResponse") public static final class PostPaymentTypesResponse { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java new file mode 100644 index 000000000..f7cc8b00f --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.paymenttype.data.request; + +import java.io.Serial; +import java.io.Serializable; + +public record PaymentTypeRequest(String name, String description, Boolean isCashPayment, Integer position, String codeName, + Boolean isSystemDefined) implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java index 072f5a903..c05051921 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java @@ -18,14 +18,14 @@ */ package org.apache.fineract.portfolio.paymenttype.service; -import java.util.Collection; +import java.util.List; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; public interface PaymentTypeReadPlatformService { - Collection retrieveAllPaymentTypes(); + List retrieveAllPaymentTypes(); - Collection retrieveAllPaymentTypesWithCode(); + List retrieveAllPaymentTypesWithCode(); PaymentTypeData retrieveOne(Long paymentTypeId); diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java index 9b6588d0d..a5825cd20 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java @@ -18,7 +18,6 @@ */ package org.apache.fineract.portfolio.paymenttype.service; -import java.util.Collection; import java.util.List; import lombok.RequiredArgsConstructor; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; @@ -37,7 +36,7 @@ public class PaymentTypeReadPlatformServiceImpl implements PaymentTypeReadPlatfo @Override @Cacheable(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") - public Collection retrieveAllPaymentTypes() { + public List retrieveAllPaymentTypes() { // TODO Auto-generated method stub this.context.authenticatedUser(); @@ -47,7 +46,7 @@ public class PaymentTypeReadPlatformServiceImpl implements PaymentTypeReadPlatfo @Override @Cacheable(value = "paymentTypesWithCode", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") - public Collection retrieveAllPaymentTypesWithCode() { + public List retrieveAllPaymentTypesWithCode() { // TODO Auto-generated method stub this.context.authenticatedUser(); diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java index 4c6919545..25364e2b3 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/paymenttype/PaymentTypeResolver.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.fineract.client.models.GetPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeData; import org.apache.fineract.client.services.PaymentTypeApi; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Component; @@ -40,13 +40,13 @@ public class PaymentTypeResolver { try { String paymentTypeName = paymentType.getName(); log.debug("Resolving payment type by name [{}]", paymentTypeName); - Response> response = paymentTypeApi.getAllPaymentTypes(false).execute(); + Response> response = paymentTypeApi.getAllPaymentTypes(false).execute(); if (!response.isSuccessful()) { throw new IllegalStateException("Unable to get payment types. Status code was HTTP " + response.code()); } - List paymentTypesResponses = response.body(); - GetPaymentTypesResponse foundPtr = paymentTypesResponses.stream().filter(ptr -> paymentTypeName.equals(ptr.getName())).findAny() + List paymentTypesResponses = response.body(); + PaymentTypeData foundPtr = paymentTypesResponses.stream().filter(ptr -> paymentTypeName.equals(ptr.getName())).findAny() .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(paymentTypeName))); return foundPtr.getId(); diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java index dbde26e99..d928cd420 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java @@ -18,15 +18,14 @@ */ package org.apache.fineract.test.factory; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; public final class PaymentTypesRequestFactory { private PaymentTypesRequestFactory() {} - public static PostPaymentTypesRequest defaultPaymentTypeRequest(String name, String description, Boolean isCashPayment, - Integer position) { - PostPaymentTypesRequest request = new PostPaymentTypesRequest(); + public static PaymentTypeRequest defaultPaymentTypeRequest(String name, String description, Boolean isCashPayment, Integer position) { + PaymentTypeRequest request = new PaymentTypeRequest(); request.name(name).description(description).isCashPayment(isCashPayment).position(position); diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java index f7cd14154..adcd3b001 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.services.PaymentTypeApi; import org.apache.fineract.test.factory.PaymentTypesRequestFactory; import org.springframework.core.Ordered; @@ -59,7 +59,7 @@ public class PaymentTypeGlobalInitializerStep implements FineractGlobalInitializ paymentTypes.forEach(paymentType -> { Integer position = paymentTypes.indexOf(paymentType) + 2; - PostPaymentTypesRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentType, paymentType, + PaymentTypeRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentType, paymentType, false, position); try { diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java index 15d6655c4..b47b218a0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java @@ -40,7 +40,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; @@ -2664,7 +2664,7 @@ public class ClientSavingsIntegrationTest { Integer position = 1; PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); @@ -2685,8 +2685,8 @@ public class ClientSavingsIntegrationTest { String paymentTypeNameTwo = PaymentTypeHelper.randomNameGenerator("P_T", 5); - PostPaymentTypesResponse paymentTypesResponseTwo = paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest() - .name(paymentTypeNameTwo).description(description).isCashPayment(isCashPayment).position(position)); + PostPaymentTypesResponse paymentTypesResponseTwo = paymentTypeHelper.createPaymentType( + new PaymentTypeRequest().name(paymentTypeNameTwo).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdTwo = paymentTypesResponseTwo.getResourceId(); Assertions.assertNotNull(paymentTypeIdTwo); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java index 3bcb868e2..adee98f18 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java @@ -35,7 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; @@ -318,7 +318,7 @@ public class GroupSavingsIntegrationTest { Integer position = 1; PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java index 06c63b642..0d9628efb 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java @@ -48,12 +48,12 @@ import org.apache.fineract.client.models.GetLoanTransactionRelation; import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse; import org.apache.fineract.client.models.JournalEntryTransactionItem; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -671,8 +671,8 @@ public class LoanAccountChargeOffWithAdvancedPaymentAllocationTest extends BaseL Boolean isCashPayment = false; Integer position = 1; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest() - .name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java index 57ab37509..bea33f1f9 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java @@ -40,11 +40,11 @@ import org.apache.fineract.client.models.ChargeToGLAccountMapper; import org.apache.fineract.client.models.GetLoanFeeToIncomeAccountMappings; import org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -363,8 +363,8 @@ public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest exte Boolean isCashPayment = false; Integer position = 1; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest() - .name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java index fd7bfe377..e1a30ffa5 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java @@ -43,11 +43,11 @@ import org.apache.fineract.client.models.GetLoanTransactionRelation; import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse; import org.apache.fineract.client.models.JournalEntryTransactionItem; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; @@ -1137,8 +1137,8 @@ public class LoanPostChargeOffScenariosTest extends BaseLoanIntegrationTest { Boolean isCashPayment = false; Integer position = 1; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest() - .name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java index 062d4990c..a3f878acc 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java @@ -24,8 +24,8 @@ import io.restassured.http.ContentType; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse; -import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeData; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; @@ -58,11 +58,11 @@ public class PaymentTypeIntegrationTest { Integer position = 1; PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId); - GetPaymentTypesPaymentTypeIdResponse paymentTypeResponse = paymentTypeHelper.retrieveById(paymentTypeId); + PaymentTypeData paymentTypeResponse = paymentTypeHelper.retrieveById(paymentTypeId); Assertions.assertEquals(name, paymentTypeResponse.getName()); Assertions.assertEquals(description, paymentTypeResponse.getDescription()); Assertions.assertEquals(isCashPayment, paymentTypeResponse.getIsCashPayment()); @@ -76,7 +76,7 @@ public class PaymentTypeIntegrationTest { paymentTypeHelper.updatePaymentType(paymentTypeId, new PutPaymentTypesPaymentTypeIdRequest().name(newName) .description(newDescription).isCashPayment(isCashPaymentUpdatedValue).position(newPosition)); - GetPaymentTypesPaymentTypeIdResponse paymentTypeUpdatedResponse = paymentTypeHelper.retrieveById(paymentTypeId); + PaymentTypeData paymentTypeUpdatedResponse = paymentTypeHelper.retrieveById(paymentTypeId); Assertions.assertEquals(newName, paymentTypeUpdatedResponse.getName()); Assertions.assertEquals(newDescription, paymentTypeUpdatedResponse.getDescription()); Assertions.assertEquals(isCashPaymentUpdatedValue, paymentTypeUpdatedResponse.getIsCashPayment()); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java index b1f14e405..8d7dd22a9 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java @@ -34,8 +34,8 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Locale; -import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeData; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; @@ -141,11 +141,11 @@ public class RepaymentWithPostDatedChecksTest { Integer position = 1; PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId); - GetPaymentTypesPaymentTypeIdResponse paymentTypeResponse = paymentTypeHelper.retrieveById(paymentTypeId); + PaymentTypeData paymentTypeResponse = paymentTypeHelper.retrieveById(paymentTypeId); Assertions.assertEquals(name, paymentTypeResponse.getName()); // Repay for the installment 1 using post dated check diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java index 0cf72e930..9ee09e73a 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java @@ -42,11 +42,11 @@ import org.apache.fineract.client.models.GetLoanFeeToIncomeAccountMappings; import org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; -import org.apache.fineract.client.models.PostPaymentTypesRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; @@ -212,8 +212,8 @@ public class UndoRepaymentWithDownPaymentIntegrationTest extends BaseLoanIntegra Boolean isCashPayment = false; Integer position = 1; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest() - .name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java index 6b2753189..309301a84 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java @@ -41,7 +41,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.UUID; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants; import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants; @@ -168,7 +168,7 @@ public class LoanImportHandlerTest { String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(paymentTypeName).description(paymentTypeDescription).isCashPayment(true).position(1)); + new PaymentTypeRequest().name(paymentTypeName).description(paymentTypeDescription).isCashPayment(true).position(1)); Long outcome_payment_creation = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java index f2ea344b6..9d8bf3014 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java @@ -26,7 +26,7 @@ import io.restassured.specification.ResponseSpecification; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import java.io.IOException; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -95,7 +95,7 @@ public class LoanWorkbookPopulatorTest { Boolean isCashPayment = true; Integer position = 1; PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long outcome_payment_creation = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java index 878d66757..942f75ff3 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java @@ -27,9 +27,8 @@ import io.restassured.specification.ResponseSpecification; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse; -import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse; -import org.apache.fineract.client.models.GetPaymentTypesResponse; -import org.apache.fineract.client.models.PostPaymentTypesRequest; +import org.apache.fineract.client.models.PaymentTypeData; +import org.apache.fineract.client.models.PaymentTypeRequest; import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest; import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdResponse; @@ -46,25 +45,25 @@ public final class PaymentTypeHelper { private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; private static final String CREATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "?" + Utils.TENANT_IDENTIFIER; - public List getAllPaymentTypes(final Boolean onlyWithCode) { + public List getAllPaymentTypes(final Boolean onlyWithCode) { log.info("-------------------------------GETTING ALL PAYMENT TYPES-------------------------------------------"); return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.getAllPaymentTypes(onlyWithCode)); } - public PostPaymentTypesResponse createPaymentType(final PostPaymentTypesRequest postPaymentTypesRequest) { + public PostPaymentTypesResponse createPaymentType(final PaymentTypeRequest paymentTypeRequest) { log.info("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------"); - return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.createPaymentType(postPaymentTypesRequest)); + return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.createPaymentType(paymentTypeRequest)); } public void verifyPaymentTypeCreatedOnServer(final Long generatedPaymentTypeID) { log.info("-------------------------------CHECK PAYMENT DETAILS-------------------------------------------"); - GetPaymentTypesPaymentTypeIdResponse response = Calls + PaymentTypeData response = Calls .ok(FineractClientHelper.getFineractClient().paymentTypes.retrieveOnePaymentType(generatedPaymentTypeID)); Long responsePaymentTypeID = response.getId(); assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN CREATING THE PAYMENT TYPE"); } - public GetPaymentTypesPaymentTypeIdResponse retrieveById(final Long paymentTypeId) { + public PaymentTypeData retrieveById(final Long paymentTypeId) { log.info("-------------------------------GETTING PAYMENT TYPE-------------------------------------------"); return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.retrieveOnePaymentType(paymentTypeId)); } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java index 58b4236c5..84bc789c2 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java @@ -62,7 +62,7 @@ import org.apache.fineract.client.models.GetLoansLoanIdSummary; import org.apache.fineract.client.models.GetLoansLoanIdTransactions; import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTemplateResponse; import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse; -import org.apache.fineract.client.models.GetPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeData; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansDelinquencyActionRequest; @@ -2687,7 +2687,7 @@ public class LoanTransactionHelper { @Deprecated(forRemoval = true) public Long applyChargebackTransaction(final Integer loanId, final Long transactionId, final String amount, final Integer paymentTypeIdx, ResponseSpecification responseSpec) { - List paymentTypeList = paymentTypeHelper.getAllPaymentTypes(false); + List paymentTypeList = paymentTypeHelper.getAllPaymentTypes(false); assertTrue(!paymentTypeList.isEmpty()); final String payload = createChargebackPayload(amount, paymentTypeList.get(paymentTypeIdx).getId());