diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationApiResource.java index a218a2bbc24..3d5a85ec11e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationApiResource.java @@ -156,4 +156,29 @@ public String updateConfiguration(@PathParam("configId") @Parameter(description return this.toApiJsonSerializer.serialize(result); } + + @PUT + @Path("/name/{configName}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "Update Global Configuration by name", description = "Updates an enable/disable global configuration item by name") + @RequestBody(required = true, content = @Content(schema = @Schema(implementation = GlobalConfigurationApiResourceSwagger.PutGlobalConfigurationsRequest.class))) + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GlobalConfigurationApiResourceSwagger.PutGlobalConfigurationsResponse.class))) }) + public String updateConfigurationByName(@PathParam("configName") @Parameter(description = "configName") final String configName, + @Parameter(hidden = true) final String apiRequestBodyAsJson) { + + // TODO: Would be better to support string based identifier in Commands and resolve the entity by name in the + // service + final GlobalConfigurationPropertyData configurationData = this.readPlatformService.retrieveGlobalConfiguration(configName); + + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .updateGlobalConfiguration(configurationData.getId()) // + .withJson(apiRequestBodyAsJson) // + .build(); + + final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + + return this.toApiJsonSerializer.serialize(result); + } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/InternalConfigurationsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/InternalConfigurationsApiResource.java index 515ebbf775f..127b4c39140 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/InternalConfigurationsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/api/InternalConfigurationsApiResource.java @@ -20,14 +20,12 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.core.UriInfo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationProperty; @@ -37,7 +35,6 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.RequestBody; @Profile(FineractProfiles.TEST) @Component @@ -61,24 +58,22 @@ public void afterPropertiesSet() throws Exception { } - @POST - @Path("{configId}/value/{configValue}") + @PUT + @Path("name/{configName}/value/{configValue}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT") - public Response updateGlobalConfiguration(@Context final UriInfo uriInfo, @PathParam("configId") Long configId, - @PathParam("configValue") Long configValue, @RequestBody(required = false) String error) { + public Response updateGlobalConfiguration(@PathParam("configName") String configName, @PathParam("configValue") Long configValue) { log.warn("------------------------------------------------------------"); log.warn(" "); - log.warn("Update trap-door config: {}", configId); + log.warn("Update trap-door config: {}", configName); log.warn(" "); log.warn("------------------------------------------------------------"); - final GlobalConfigurationProperty config = repository.findOneWithNotFoundDetection(configId); - log.warn("Config to be updated {} original value {}", config.getName(), config.getValue()); + final GlobalConfigurationProperty config = repository.findOneByNameWithNotFoundDetection(configName); config.setValue(configValue); repository.save(config); - log.warn("Config to be updated to {}", config.getValue()); + log.warn("Config {} updated to {}", config.getName(), config.getValue()); repository.removeFromCache(config.getName()); MoneyHelper.fetchRoundingModeFromGlobalConfig(); diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml index cac890a8943..38c4a9be108 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml @@ -28,8 +28,8 @@ + 9:64863870bbd61795b1a8ced20a6dd7a3 - diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java index f0dc525d2e5..0f3d551b0b0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java @@ -67,7 +67,6 @@ import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.LoanRescheduleRequestHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -4070,15 +4069,15 @@ public void uc136() { AtomicLong createdLoanId = new AtomicLong(); runAt("23 March 2024", () -> { // Rounding mode - HALF_DOWN - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 5); + globalConfigurationHelper.updateGlobalConfigurationInternal("rounding-mode", 5L); createLoanForRoundingMethodValidation(true); // Rounding mode - HALF_UP - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 4); + globalConfigurationHelper.updateGlobalConfigurationInternal("rounding-mode", 4L); createLoanForRoundingMethodValidation(false); // Rounding mode - HALF_EVEN - Default - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 6); + globalConfigurationHelper.updateGlobalConfigurationInternal("rounding-mode", 6L); }); } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java index 1a4e225e5e8..8cd7e221d6a 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java @@ -18,8 +18,6 @@ */ package org.apache.fineract.integrationtests; -import static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; import static org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE; import static org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder.DUE_PENALTY_INTEREST_PRINCIPAL_FEE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE_STRATEGY; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -70,6 +68,7 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoansLoanIdResponse; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.integrationtests.common.BatchHelper; @@ -150,6 +149,7 @@ public abstract class BaseLoanIntegrationTest { createResponseSpecification(Matchers.is(202))); protected BusinessDateHelper businessDateHelper = new BusinessDateHelper(); protected DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATETIME_PATTERN); + protected GlobalConfigurationHelper globalConfigurationHelper = new GlobalConfigurationHelper(); protected static void validateRepaymentPeriod(GetLoansLoanIdResponse loanDetails, Integer index, LocalDate dueDate, double principalDue, double principalPaid, double principalOutstanding, double paidInAdvance, double paidLate) { @@ -658,14 +658,17 @@ protected void verifyRepaymentSchedule(Long loanId, Installment... installments) protected void runAt(String date, Runnable runnable) { try { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 42, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, TRUE); + // globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + // new PutGlobalConfigurationsRequest().enabled(TRUE)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate( new BusinessDateRequest().type(BUSINESS_DATE.getName()).date(date).dateFormat(DATETIME_PATTERN).locale("en")); runnable.run(); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, FALSE); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 42, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + // globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + // new PutGlobalConfigurationsRequest().enabled(FALSE)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java index 0b274ff7f3c..1fdbef01127 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BatchApiTest.java @@ -48,17 +48,16 @@ import org.apache.fineract.batch.command.internal.GetDatatableEntryByAppTableIdAndDataTableIdCommandStrategy; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.integrationtests.common.BatchHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.error.ErrorResponse; import org.apache.fineract.integrationtests.common.loans.LoanAccountLockHelper; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper; @@ -73,12 +72,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@ExtendWith(LoanTestLifecycleExtension.class) -public class BatchApiTest { +public class BatchApiTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(BatchApiTest.class); @@ -113,12 +110,14 @@ public void setup() { this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(this.requestSpec, this.responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); } @AfterEach public void postActions() { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(this.requestSpec, this.responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } /** diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientExternalIdTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientExternalIdTest.java index 438e141bb5c..4b35d972a4c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientExternalIdTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientExternalIdTest.java @@ -50,6 +50,7 @@ public class ClientExternalIdTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -57,13 +58,13 @@ public void setup() { requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test public void whenAutoExternalIdConfigIsOffCreateClient() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -92,8 +93,7 @@ public void whenAutoExternalIdConfigIsOffCreateClientWithValue() { @Test public void whenAutoExternalIdConfigIsOnCreateClient() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -105,15 +105,13 @@ public void whenAutoExternalIdConfigIsOnCreateClient() { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void whenAutoExternalIdConfigIsOnCreateClientWithValue() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String externalId = UUID.randomUUID().toString(); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, externalId); @@ -126,15 +124,13 @@ public void whenAutoExternalIdConfigIsOnCreateClientWithValue() { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testClientStatusUsingExternalId() { ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); final PostClientsResponse addClientResponse = ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload); final String clientExternalId = addClientResponse.getResourceExternalId(); @@ -202,15 +198,13 @@ public void testClientStatusUsingExternalId() { ClientStatusChecker.verifyClientStatus(ClientStatus.ACTIVE, clientResponse); log.info("Client data id {} and status {}", clientExternalId, clientResponse.getStatus().getCode()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testUpdateClientUsingExternalId() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when final PostClientsResponse clientResponse = ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload); @@ -223,16 +217,14 @@ public void testUpdateClientUsingExternalId() { assertNotNull(clientUpdateResponse.getResourceExternalId()); assertEquals(clientExternalId, clientUpdateResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testDeleteClientUsingExternalId() { // given ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when final PostClientsResponse clientResponse = ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload); @@ -250,15 +242,13 @@ public void testDeleteClientUsingExternalId() { assertNotNull(clientDeleteResponse.getResourceExternalId()); assertEquals(clientExternalId, clientDeleteResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testGetClientAccountsUsingExternalId() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -271,15 +261,13 @@ public void testGetClientAccountsUsingExternalId() { // then assertNotNull(clientAccountsResponse); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testGetClientTransferProposalDate() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); final PostClientsResponse clientResponse = ClientHelper.addClientAsPerson(requestSpec, responseSpec, jsonPayload); @@ -292,15 +280,13 @@ public void testGetClientTransferProposalDate() { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @Test public void testGetClientObligeeData() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -313,8 +299,7 @@ public void testGetClientObligeeData() { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } private void fetchClientByExternalId(final String externalId) { diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java index e372e38a7c4..0d7eedee341 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java @@ -86,13 +86,13 @@ import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; import org.apache.fineract.client.models.PutChargeTransactionChangesRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -105,7 +105,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductHelper; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.savings.AccountTransferHelper; import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; @@ -117,7 +116,6 @@ import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.platform.commons.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,9 +125,8 @@ * repayments and verifying accounting transactions */ @SuppressWarnings({ "rawtypes", "unchecked" }) -@ExtendWith(LoanTestLifecycleExtension.class) @SuppressFBWarnings(value = "RV_EXCEPTION_NOT_THROWN", justification = "False positive") -public class ClientLoanIntegrationTest { +public class ClientLoanIntegrationTest extends BaseLoanIntegrationTest { static { Utils.initializeRESTAssured(); @@ -2545,8 +2542,7 @@ public void loanWithFlatChargesAndPeriodicAccrualAccountingEnabled() throws Inte @Test public void loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEnabled() throws InterruptedException { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID); @@ -2745,8 +2741,7 @@ public void loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEna loanStatusHashMap = LOAN_TRANSACTION_HELPER.getLoanDetail(REQUEST_SPEC, RESPONSE_SPEC, loanID, "status"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } finally { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } } @@ -3446,7 +3441,8 @@ public void testInteroperationLoanRepaymentAPI() { try { DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); startDate.add(Calendar.MONTH, -8); @@ -3495,7 +3491,8 @@ public void testInteroperationLoanRepaymentAPI() { HashMap loanRepayment = LOAN_TRANSACTION_HELPER.makeRepaymentWithAccountNo(loanFirstRepaymentDate, earlyPayment, accountNo); assertNotNull(loanRepayment); } finally { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -4933,7 +4930,8 @@ public void testLoanScheduleWithInterestRecalculationMakePrepaymentAfterRepaymen try { DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); startDate.add(Calendar.MONTH, -8); @@ -4987,7 +4985,8 @@ public void testLoanScheduleWithInterestRecalculationMakePrepaymentAfterRepaymen loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } finally { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -4998,7 +4997,8 @@ public void testLoanScheduleWithInterestRecalculationMakeAdvancePaymentTillSettl final LoanTransactionHelper validationErrorHelper = new LoanTransactionHelper(REQUEST_SPEC, errorResponse); DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); startDate.add(Calendar.MONTH, -8); @@ -5062,7 +5062,8 @@ public void testLoanScheduleWithInterestRecalculationMakeAdvancePaymentTillSettl ArrayList error = (ArrayList) savingsAccountErrorData.get("errors"); assertEquals("error.msg.loan.transaction.cannot.be.a.future.date", error.get(0).get("userMessageGlobalisationCode")); } finally { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -5182,7 +5183,7 @@ public void chargeAdjustmentChargeDoesNotExistForLoan() { @Test public void chargeAdjustmentForUnpaidCharge() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("01 November 2022").dateFormat(DATETIME_PATTERN).locale("en")); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); @@ -5344,14 +5345,15 @@ public void chargeAdjustmentForUnpaidCharge() { assertEquals(0.0f, loanSummary.get("principalPaid")); assertEquals(1005.0f, loanSummary.get("totalOutstanding")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void chargeAdjustmentAccountingValidation() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("01 November 2022").dateFormat(DATETIME_PATTERN).locale("en")); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); @@ -5509,8 +5511,7 @@ public void chargeAdjustmentAccountingValidation() { Integer feeLoanChargeId = LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge.getResourceId()), feeCharge1AddedDate, "3")); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String feeLoanChargeDate = DATE_TIME_FORMATTER.format(targetDate); PERIODIC_ACCRUAL_ACCOUNTING_HELPER.runPeriodicAccrualAccounting(feeLoanChargeDate); @@ -5740,9 +5741,9 @@ public void chargeAdjustmentAccountingValidation() { assertTrue(loanDetails.getStatus().getOverpaid()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } } @@ -6030,8 +6031,9 @@ public void undoWaivedCharge() { @Test public void chargeOff() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("30 September 2022").dateFormat(DATETIME_PATTERN).locale("en")); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); @@ -6276,15 +6278,18 @@ public void chargeOff() { LOAN_TRANSACTION_HELPER.makeCreditBalanceRefund((long) loanID, new PostLoansLoanIdTransactionsRequest() .dateFormat(DATETIME_PATTERN).transactionDate("08 September 2022").locale("en").transactionAmount(3007.0)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testCloseOpenMaturityDate() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount(); final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount(); @@ -6338,14 +6343,16 @@ public void testCloseOpenMaturityDate() { assertTrue(expectedMaturityDate.isEqual(actualMaturityDate)); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testReverseReplay() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount(); final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount(); @@ -6475,15 +6482,17 @@ public void testReverseReplay() { assertEquals(290.0, loanDetails.getTransactions().get(5).getOverpaymentPortion()); assertEquals(LocalDate.of(2022, 9, 7), loanDetails.getTransactions().get(5).getDate()); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testCreditBalanceRefundAfterMaturityWithReverseReplayOfRepayments() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("10 October 2022").dateFormat(DATETIME_PATTERN).locale("en")); @@ -6606,16 +6615,19 @@ public void testCreditBalanceRefundAfterMaturityWithReverseReplayOfRepayments() .count()); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testCreditBalanceRefundBeforeMaturityWithReverseReplayOfRepaymentsAndRefund() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("10 October 2022").dateFormat(DATETIME_PATTERN).locale("en")); @@ -6734,16 +6746,19 @@ public void testCreditBalanceRefundBeforeMaturityWithReverseReplayOfRepaymentsAn assertEquals(700.0, loanDetails.getRepaymentSchedule().getPeriods().get(1).getPrincipalOutstanding()); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void accrualIsCalculatedWhenTheLoanIsClosed() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("10 October 2022").dateFormat(DATETIME_PATTERN).locale("en")); @@ -6811,16 +6826,19 @@ public void accrualIsCalculatedWhenTheLoanIsClosed() { }); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanTransactionOrderAfterReverseReplay() { try { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("01 January 2023").dateFormat(DATETIME_PATTERN).locale("en")); LOG.info("-----------------------------------NEW CLIENT-----------------------------------------"); @@ -6882,8 +6900,10 @@ public void testLoanTransactionOrderAfterReverseReplay() { .transactionAmount(0.0).locale("en")); checkLoanTransactionOrder(loanId, loanDisbursementUUID, firstRepaymentUUID, secondRepaymentUUID, thirdRepaymentUUID); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -8049,7 +8069,8 @@ private PostLoansResponse applyForLoanApplicationForOnePeriod30DaysLongNoInteres .loanTermFrequencyType(0).principal(BigDecimal.valueOf(1000.0)).loanType("individual")); } - private PostLoanProductsRequest createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() { + @Override + protected PostLoanProductsRequest createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() { return new PostLoanProductsRequest().name(Utils.uniqueRandomStringGenerator("LOAN_PRODUCT_", 6))// .shortName(Utils.uniqueRandomStringGenerator("", 4))// .description("Loan Product Description")// 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 df0cfd9254a..3850d22559e 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 @@ -41,6 +41,7 @@ import java.util.Locale; 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; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -85,6 +86,7 @@ public class ClientSavingsIntegrationTest { private SavingsProductHelper savingsProductHelper; private SchedulerJobHelper scheduleJobHelper; private PaymentTypeHelper paymentTypeHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -94,6 +96,7 @@ public void setup() { this.requestSpec.header("Fineract-Platform-TenantId", "default"); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.paymentTypeHelper = new PaymentTypeHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -226,7 +229,8 @@ public void testSavingsBackedDatedTransactionsNotAllowed() { Assertions.assertNotNull(summaryAfterPosting.get("interestPostedTillDate")); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", false); + globalConfigurationHelper.updateGlobalConfiguration("allow-backdated-transaction-before-interest-posting", + new PutGlobalConfigurationsRequest().enabled(false)); final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build(); final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse); @@ -242,7 +246,8 @@ public void testSavingsBackedDatedTransactionsNotAllowed() { List error = (List) validationErrorHelper.depositToSavingsAccount(savingsId, "3000", depositDate, CommonConstants.RESPONSE_ERROR); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", true); + globalConfigurationHelper.updateGlobalConfiguration("allow-backdated-transaction-before-interest-posting", + new PutGlobalConfigurationsRequest().enabled(true)); // LOG.info(savingsAccountErrorData.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).toString()); assertEquals("error.msg.savings.transaction.is.not.allowed", error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); @@ -635,7 +640,7 @@ public void testSavingsAccountTransactions() { public void testSavingsAccountCharges() { Integer savingsId = null; try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate submittedDate = LocalDate.of(2022, 9, 28); String submittedDateString = "28 September 2022"; @@ -806,7 +811,8 @@ public void testSavingsAccountCharges() { } finally { BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2024, 11, 11)); savingsAccountHelper.closeSavingsAccountOnDate(savingsId, "true", "11 November 2024"); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -3081,7 +3087,8 @@ public void testReversalEntriesAfterSystemReversingTransactionWithReversalConfig this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.scheduleJobHelper = new SchedulerJobHelper(requestSpec); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "46", true); + globalConfigurationHelper.updateGlobalConfiguration("enable-post-reversal-txns-for-reverse-transactions", + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate transactionDate = LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(5); LocalDate nextTransactionDate = transactionDate.plusDays(2); final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy"); @@ -3113,7 +3120,8 @@ public void testReversalEntriesAfterSystemReversingTransactionWithReversalConfig this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.scheduleJobHelper = new SchedulerJobHelper(requestSpec); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "46", false); + globalConfigurationHelper.updateGlobalConfiguration("enable-post-reversal-txns-for-reverse-transactions", + new PutGlobalConfigurationsRequest().enabled(false)); LocalDate transactionDate = LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(5); LocalDate nextTransactionDate = transactionDate.plusDays(2); final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy"); @@ -3207,14 +3215,15 @@ private Integer createSavingsProductDailyPostingOverdraft() { } public void configurationForBackdatedTransaction() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", false); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "39", true); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(requestSpec, responseSpec, "39", "5"); + globalConfigurationHelper.updateGlobalConfiguration("allow-backdated-transaction-before-interest-posting", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("allow-backdated-transaction-before-interest-posting-date-for-days", + new PutGlobalConfigurationsRequest().enabled(true).value(5L)); } @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java index 1012537aefc..6942f6140a8 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java @@ -35,7 +35,6 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; -import org.apache.commons.lang3.BooleanUtils; import org.apache.fineract.client.models.GetClientClientIdAddressesResponse; import org.apache.fineract.client.models.GetClientsClientIdResponse; import org.apache.fineract.client.models.GlobalConfigurationPropertyData; @@ -43,6 +42,7 @@ import org.apache.fineract.client.models.PostClientClientIdAddressesResponse; import org.apache.fineract.client.models.PostClientsAddressRequest; import org.apache.fineract.client.models.PostClientsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -58,6 +58,7 @@ public class ClientTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private ClientHelper clientHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -66,12 +67,13 @@ public void setup() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); clientHelper = new ClientHelper(requestSpec, responseSpec); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(requestSpec, responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(requestSpec, responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } @Test @@ -203,15 +205,10 @@ public void testPendingOnlyClientRequest() { @Test public void testClientAddressCreationWorks() { // given - GlobalConfigurationPropertyData addressEnabledConfig = GlobalConfigurationHelper.getGlobalConfigurationByName(requestSpec, - responseSpec, "Enable-Address"); - Long configId = addressEnabledConfig.getId(); - - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configId, true); - GlobalConfigurationPropertyData updatedAddressEnabledConfig = GlobalConfigurationHelper.getGlobalConfigurationByName(requestSpec, - responseSpec, "Enable-Address"); - boolean isAddressEnabled = BooleanUtils.toBoolean(updatedAddressEnabledConfig.getEnabled()); - assertThat(isAddressEnabled).isTrue(); + globalConfigurationHelper.updateGlobalConfiguration("Enable-Address", new PutGlobalConfigurationsRequest().enabled(true)); + GlobalConfigurationPropertyData updatedAddressEnabledConfig = globalConfigurationHelper + .getGlobalConfigurationByName("Enable-Address"); + assertThat(updatedAddressEnabledConfig.getEnabled()).isTrue(); Integer addressTypeId = CodeHelper.createAddressTypeCodeValue(requestSpec, responseSpec, Utils.randomStringGenerator("Residential address", 4), 0); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java index 3c1856499f7..11b69d575ef 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java @@ -46,16 +46,15 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PaymentAllocationOrder; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus; @@ -63,14 +62,12 @@ import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Named; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @Slf4j -@ExtendWith(LoanTestLifecycleExtension.class) -public class DelinquencyAndChargebackIntegrationTest { +public class DelinquencyAndChargebackIntegrationTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -93,7 +90,7 @@ public void setup() { @MethodSource("loanProductFactory") public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getDateAsLocalDate("01 April 2012"); LocalDate businessDate = todaysDate.minusMonths(3); @@ -205,7 +202,8 @@ public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder loanPro getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); validateLoanAccount(getLoansLoanIdResponse, amountVal, "950.00", 4, Double.valueOf("50.00")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -213,7 +211,7 @@ public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder loanPro @MethodSource("loanProductFactory") public void testLoanClassificationStepAsPartOfCOBRepeated(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); List expectedDates = new ArrayList(); @@ -336,7 +334,8 @@ public void testLoanClassificationStepAsPartOfCOBRepeated(LoanProductTestBuilder } } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java index 23788e1fe84..efb6f1c8bcf 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyBucketsIntegrationTest.java @@ -63,6 +63,7 @@ import org.apache.fineract.client.models.PostLoansResponse; import org.apache.fineract.client.models.PutDelinquencyBucketResponse; import org.apache.fineract.client.models.PutDelinquencyRangeResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdResponse; import org.apache.fineract.cob.data.JobBusinessStepConfigData; @@ -71,7 +72,6 @@ import org.apache.fineract.integrationtests.common.BusinessStepConfigurationHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; @@ -314,7 +314,7 @@ public void testLoanClassificationRealtime() { try { // Given final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 March 2012"); log.info("Current date {}", bussinesLocalDate); @@ -402,14 +402,15 @@ public void testLoanClassificationRealtime() { assertEquals(getDelinquencyTagsHistory.get(0).getDelinquencyRange().getClassification(), classificationExpected); log.info("Delinquency Tag Item with Lifted On {}", getDelinquencyTagsHistory.get(0).getLiftedOnDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationRealtimeWithCharges() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012"); log.info("Current date {}", bussinesLocalDate); @@ -497,7 +498,8 @@ public void testLoanClassificationRealtimeWithCharges() { // Evaluate a Delinquency Tag set after add charge to the Loan assertEquals(getLoansLoanIdResponse.getDelinquencyRange().getClassification(), classificationExpected); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -711,7 +713,7 @@ public void testLoanClassificationRealtimeWithReversedRepayment() { @Test public void testLoanClassificationJob() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = Utils.getLocalDateOfTenant(); businessDate = businessDate.minusDays(37); @@ -794,14 +796,15 @@ public void testLoanClassificationJob() { assertEquals(secondTestCase.getClassification(), classificationExpected); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationStepAsPartOfCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012"); log.info("Current date {}", bussinesLocalDate); @@ -896,14 +899,15 @@ public void testLoanClassificationStepAsPartOfCOB() { assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName()); assertEquals(secondTestCase.getClassification(), classificationExpected); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationToValidateNegatives() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012"); log.info("Current date {}", bussinesLocalDate); @@ -975,14 +979,15 @@ public void testLoanClassificationToValidateNegatives() { assertEquals(0, getLoansLoanIdCollectionData.getPastDueDays()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationUsingAgeingArrears() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012"); log.info("Current date {}", bussinesLocalDate); @@ -1064,7 +1069,8 @@ public void testLoanClassificationUsingAgeingArrears() { assertEquals(0, getLoansLoanIdCollectionData.getPastDueDays()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1394,7 +1400,7 @@ public void testLoanClassificationOnlyForActiveLoan() { @Test public void testLoanClassificationOnlyForActiveLoanWithCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final String operationDate = "01 January 2012"; LocalDate bussinesLocalDate = Utils.getDateAsLocalDate(operationDate); @@ -1445,7 +1451,8 @@ public void testLoanClassificationOnlyForActiveLoanWithCOB() { assertEquals(0, delinquent.getDelinquentAmount()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DueDateRespectiveLoanRepaymentScheduleTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DueDateRespectiveLoanRepaymentScheduleTest.java index 26459b6337b..e06255dda87 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DueDateRespectiveLoanRepaymentScheduleTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DueDateRespectiveLoanRepaymentScheduleTest.java @@ -39,10 +39,10 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.LoanRescheduleRequestHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -52,17 +52,14 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@ExtendWith(LoanTestLifecycleExtension.class) -public class DueDateRespectiveLoanRepaymentScheduleTest { +public class DueDateRespectiveLoanRepaymentScheduleTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(DueDateRespectiveLoanRepaymentScheduleTest.class); private ResponseSpecification responseSpec; @@ -100,7 +97,7 @@ public void setup() { @Test public void scenario1() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -188,7 +185,8 @@ public void scenario1() { assertEquals(1, response.getTransactions().get(3).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -209,7 +207,7 @@ public void scenario1() { @Test public void scenario2() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -305,7 +303,8 @@ public void scenario2() { assertEquals(firstChargeId, response.getTransactions().get(3).getLoanChargePaidByList().get(0).getChargeId().intValue()); assertEquals(1, response.getTransactions().get(3).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -320,7 +319,7 @@ public void scenario2() { @Test public void scenario3() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -423,7 +422,8 @@ public void scenario3() { response.getTransactions().get(repaymentOrderNo).getLoanChargePaidByList().get(0).getChargeId().intValue()); assertEquals(1, response.getTransactions().get(repaymentOrderNo).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -437,7 +437,7 @@ public void scenario3() { @Test public void scenario4() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -511,7 +511,8 @@ public void scenario4() { assertEquals(1, response.getTransactions().get(1).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -526,7 +527,7 @@ public void scenario4() { @Test public void scenario5() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -660,7 +661,8 @@ public void scenario5() { assertEquals(0.0, response.getTransactions().get(secondRepaymentIndex).getOutstandingLoanBalance()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -674,7 +676,7 @@ public void scenario5() { @Test public void scenario6() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.03.01").dateFormat("yyyy.MM.dd").locale("en")); @@ -735,7 +737,8 @@ public void scenario6() { assertEquals(1, response.getTransactions().get(1).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -749,7 +752,7 @@ public void scenario6() { @Test public void scenario7() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.01.28").dateFormat("yyyy.MM.dd").locale("en")); @@ -869,7 +872,8 @@ public void scenario7() { assertEquals(1, response.getTransactions().get(2).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -884,7 +888,7 @@ public void scenario7() { @Test public void scenario8() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.15").dateFormat("yyyy.MM.dd").locale("en")); @@ -1090,7 +1094,8 @@ public void scenario8() { assertEquals(1, response.getTransactions().get(4).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1108,7 +1113,7 @@ public void scenario8() { @Test public void scenario9() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.15").dateFormat("yyyy.MM.dd").locale("en")); @@ -1400,7 +1405,8 @@ public void scenario9() { assertEquals(2, response.getTransactions().get(5).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1414,10 +1420,11 @@ public void scenario9() { @Test public void scenario10() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.05.14").dateFormat("yyyy.MM.dd").locale("en")); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(requestSpec, responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); final Account assetAccount = this.accountHelper.createAssetAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount(); @@ -1593,8 +1600,10 @@ public void scenario10() { assertEquals(0.0, loanDetails.getTransactions().get(4).getOutstandingLoanBalance()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(requestSpec, responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -1608,10 +1617,11 @@ public void scenario10() { @Test public void scenario11() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.05.14").dateFormat("yyyy.MM.dd").locale("en")); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(requestSpec, responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); final Account assetAccount = this.accountHelper.createAssetAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount(); @@ -1787,8 +1797,10 @@ public void scenario11() { assertEquals(2.95, loanDetails.getTransactions().get(4).getFeeChargesPortion()); assertEquals(0.0, loanDetails.getTransactions().get(4).getOutstandingLoanBalance()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(requestSpec, responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalIdSupportIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalIdSupportIntegrationTest.java index 66899514b6f..a0a785d0ba0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalIdSupportIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalIdSupportIntegrationTest.java @@ -23,11 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import io.restassured.builder.RequestSpecBuilder; -import io.restassured.builder.ResponseSpecBuilder; -import io.restassured.http.ContentType; -import io.restassured.specification.RequestSpecification; -import io.restassured.specification.ResponseSpecification; import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -61,58 +56,35 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; import org.apache.fineract.client.models.PutChargeTransactionChangesRequest; import org.apache.fineract.client.models.PutChargeTransactionChangesResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoansLoanIdChargesChargeIdRequest; import org.apache.fineract.client.models.PutLoansLoanIdChargesChargeIdResponse; import org.apache.fineract.client.models.PutLoansLoanIdRequest; import org.apache.fineract.client.models.PutLoansLoanIdResponse; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; -import org.apache.fineract.integrationtests.client.IntegrationTest; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; -import org.apache.fineract.integrationtests.common.accounting.AccountHelper; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.organisation.StaffHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyRangesHelper; import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class ExternalIdSupportIntegrationTest extends IntegrationTest { - - private ResponseSpecification responseSpec; - private RequestSpecification requestSpec; - - private ClientHelper clientHelper; - private AccountHelper accountHelper; - private LoanTransactionHelper loanTransactionHelper; +public class ExternalIdSupportIntegrationTest extends BaseLoanIntegrationTest { private DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); - @BeforeAll - public void init() { - Utils.initializeRESTAssured(); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); - this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); - this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - } - @Test public void test() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, true); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); final Account assetAccount = this.accountHelper.createAssetAccount(); final Account assetFeeAndPenaltyAccount = this.accountHelper.createAssetAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount(); @@ -691,7 +663,8 @@ inAdvanceRepayment2TxnExternalIdStr, new PostLoansLoanIdTransactionsTransactionI response = loanTransactionHelper.getLoanTransactionDetails(loanExternalIdStr, payChargeExternalIdStr); assertEquals(payChargeExternalIdStr, response.getExternalId()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, false); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } @Test @@ -854,8 +827,9 @@ public void negativeTest() { @Test public void loan() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); new BusinessDateHelper().updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2022.10.10").dateFormat("yyyy.MM.dd").locale("en")); try { @@ -1105,8 +1079,10 @@ public void loan() { assertEquals(transactionExternalId3, chargeOffResult.getResourceExternalId()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("enable-auto-generated-external-id", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java index 7ca4884d442..59c7af842b7 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; @@ -52,6 +53,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest { private RequestSpecification requestSpec; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +63,7 @@ public void setup() { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -71,7 +74,7 @@ public void testSavingsInterestPostingAtPeriodEnd() { Assertions.assertNotNull(clientID); // Configuring global config flags - configureInterestPosting(true, 4); + configureInterestPosting(true, 4L); final Integer savingsId = createSavingsAccount(clientID, startDate); @@ -108,36 +111,16 @@ private Integer createSavingsAccount(final Integer clientID, final String startD return savingsId; } - private void configureInterestPosting(final Boolean periodEndEnable, final Integer financialYearBeginningMonth) { - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - + private void configureInterestPosting(final Boolean periodEndEnable, final Long financialYearBeginningMonth) { // Updating flag for interest posting at period end - Integer periodEndConfigId = (Integer) globalConfig.get(10).get("id"); - Assertions.assertNotNull(periodEndConfigId); - - HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - periodEndConfigId.toString()); - Assertions.assertNotNull(periodEndConfigData); - - Boolean enabled = (Boolean) globalConfig.get(10).get("enabled"); - - if (!enabled.equals(periodEndEnable)) { - periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, - periodEndConfigId.toString(), periodEndEnable); - } + String periodEndConfigName = "savings-interest-posting-current-period-end"; + globalConfigurationHelper.updateGlobalConfiguration(periodEndConfigName, + new PutGlobalConfigurationsRequest().enabled(periodEndEnable)); // Updating value for financial year beginning month - Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id"); - Assertions.assertNotNull(financialYearBeginningConfigId); - - HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - financialYearBeginningConfigId.toString()); - Assertions.assertNotNull(financialYearBeginningConfigData); - - financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, - financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString()); - Assertions.assertNotNull(financialYearBeginningConfigId); + String financialYearBeginningConfigName = "financial-year-beginning-month"; + globalConfigurationHelper.updateGlobalConfiguration(financialYearBeginningConfigName, + new PutGlobalConfigurationsRequest().value(financialYearBeginningMonth)); } private Integer createSavingsProduct() { @@ -149,8 +132,8 @@ private Integer createSavingsProduct() { // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest.java deleted file mode 100644 index bbb539aed59..00000000000 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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.integrationtests; - -import io.restassured.builder.RequestSpecBuilder; -import io.restassured.builder.ResponseSpecBuilder; -import io.restassured.http.ContentType; -import io.restassured.specification.RequestSpecification; -import io.restassured.specification.ResponseSpecification; -import java.util.ArrayList; -import java.util.HashMap; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; -import org.apache.fineract.integrationtests.common.Utils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class GlobalConfigInterestChargedFromDateSameAsDisbursalDateTest { - - private ResponseSpecification responseSpec; - private RequestSpecification requestSpec; - private GlobalConfigurationHelper globalConfigurationHelper; - - @BeforeEach - public void setup() { - Utils.initializeRESTAssured(); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); - this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - } - - @AfterEach - public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - } - - @SuppressWarnings({ "static-access", "rawtypes", "unchecked" }) - @Test - public void testInterestChargedFromDateSameAsDisbursalDate() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - - String configName = "interest-charged-from-date-same-as-disbursal-date"; - boolean newBooleanValue = true; - - for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(configName)) { - String configId = globalConfig.get(configIndex).get("id").toString(); - Integer updateConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, - this.responseSpec, configId.toString(), newBooleanValue); - Assertions.assertNotNull(updateConfigId); - break; - } - } - - } - -} diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java index d536a396a96..458b5177ab3 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java @@ -18,14 +18,19 @@ */ package org.apache.fineract.integrationtests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import io.restassured.builder.RequestSpecBuilder; import io.restassured.builder.ResponseSpecBuilder; import io.restassured.http.ContentType; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; -import java.util.ArrayList; -import java.util.HashMap; -import org.apache.fineract.integrationtests.common.CommonConstants; +import org.apache.fineract.client.models.GetGlobalConfigurationsResponse; +import org.apache.fineract.client.models.GlobalConfigurationPropertyData; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.AfterEach; @@ -40,7 +45,6 @@ public class GlobalConfigurationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private GlobalConfigurationHelper globalConfigurationHelper; - private ResponseSpecification httpStatusForidden; @BeforeEach public void setup() { @@ -48,205 +52,58 @@ public void setup() { this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.httpStatusForidden = new ResponseSpecBuilder().expectStatusCode(403).build(); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } @Test public void testGlobalConfigurations() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - - String configName = "penalty-wait-period"; - for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(configName)) { - Integer configId = (Integer) globalConfig.get(configIndex).get("id"); - Assertions.assertNotNull(configId); - - HashMap configDataBefore = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - Assertions.assertNotNull(configDataBefore); - - Integer value = (Integer) configDataBefore.get("value") + 1; - - // Updating Value for penalty-wait-period Global Configuration - configId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, - configId.toString(), value.toString()); - Assertions.assertNotNull(configId); - - HashMap configDataAfter = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - - // Verifying Value for penalty-wait-period after Updation - Assertions.assertEquals(value, configDataAfter.get("value"), "Verifying Global Config Value after Updation"); - - // Updating Enabled Flag for penalty-wait-period Global - // Configuration - Boolean enabled = (Boolean) globalConfig.get(configIndex).get("enabled"); - - if (enabled == true) { - enabled = false; - } else { - enabled = true; - } - - configId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, - configId.toString(), enabled); - - configDataAfter = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - - // Verifying Enabled Flag for penalty-wait-period after Updation - Assertions.assertEquals(enabled, configDataAfter.get("enabled"), "Verifying Enabled Flag Global Config after Updation"); - break; - } - } - } - - @Test - public void testGlobalConfigurationsEnableDisable() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); + final GetGlobalConfigurationsResponse globalConfig = globalConfigurationHelper.getAllGlobalConfigurations(); Assertions.assertNotNull(globalConfig); - String configName = "enable_payment_hub_integration"; - for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(configName)) { - Integer configId = (Integer) globalConfig.get(configIndex).get("id"); - Assertions.assertNotNull(configId); - - HashMap configDataBefore = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - Assertions.assertNotNull(configDataBefore); - - Integer value = (Integer) configDataBefore.get("value") + 1; - - // Updating Enabled Flag for use-payment-hub Global - // Configuration - Boolean enabled = (Boolean) globalConfig.get(configIndex).get("enabled"); - - if (enabled == true) { - enabled = false; - } else { - enabled = true; - } - - configId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, - configId.toString(), enabled); - - HashMap configDataAfter = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - - // Verifying Enabled Flag for use-payment-hub after Updation - Assertions.assertEquals(enabled, configDataAfter.get("enabled"), "Verifying Enabled Flag Global Config after Updation"); - break; - } - } } @Test - public void testGlobalConfigurationIsCacheEnabled() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - - // Retrieving Is Cache Enabled Global Configuration details - ArrayList isCacheGlobalConfig = GlobalConfigurationHelper.getGlobalConfigurationIsCacheEnabled(this.requestSpec, - this.responseSpec); - Assertions.assertNotNull(isCacheGlobalConfig); - - for (Integer cacheType = 0; cacheType <= isCacheGlobalConfig.size() - 1; cacheType++) { - - // Retrieving Is Cache Enabled Global Configuration details - isCacheGlobalConfig = GlobalConfigurationHelper.getGlobalConfigurationIsCacheEnabled(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(isCacheGlobalConfig); - - HashMap cacheTypeAsHashMap = (HashMap) isCacheGlobalConfig.get(cacheType).get("cacheType"); - Integer cacheTypeId = (Integer) cacheTypeAsHashMap.get("id"); - String cacheTypeValue = (String) cacheTypeAsHashMap.get("value"); - Boolean enabled = (Boolean) isCacheGlobalConfig.get(cacheType).get("enabled"); - - if (cacheTypeValue.compareTo("No cache") == 0 && enabled == true) { - cacheTypeId += 1; - } else if (cacheTypeValue.compareTo("Single node") == 0 && enabled == true) { - cacheTypeId -= 1; - } - - HashMap changes = GlobalConfigurationHelper.updateIsCacheEnabledForGlobalConfiguration(this.requestSpec, this.responseSpec, - cacheTypeId.toString()); - Assertions.assertEquals(cacheTypeId, changes.get("cacheType"), "Verifying Is Cache Enabled Global Config after Updation"); + public void testGlobalConfigurationUpdate() { + String configName = "penalty-wait-period"; + GlobalConfigurationPropertyData config = globalConfigurationHelper.getGlobalConfigurationByName(configName); + try { + Assertions.assertNotNull(config); + Assertions.assertNotNull(config.getValue()); + Long newValue = config.getValue() + 1; + Assertions.assertNotNull(config.getEnabled()); + // Updating Value for penalty-wait-period Global Configuration + boolean newEnabledValue = !config.getEnabled(); + // Updating Enabled Flag for penalty-wait-period Global + // Configuration + globalConfigurationHelper.updateGlobalConfiguration(config.getName(), + new PutGlobalConfigurationsRequest().value(newValue).enabled(newEnabledValue)); + GlobalConfigurationPropertyData updatedConfiguration = globalConfigurationHelper.getGlobalConfigurationByName(configName); + // Verifying Value for penalty-wait-period after the update + Assertions.assertEquals(newValue, updatedConfiguration.getValue(), "Verifying Global Config Value after the update"); + // Verifying Enabled Flag for penalty-wait-period after Updation + Assertions.assertEquals(newEnabledValue, updatedConfiguration.getEnabled(), + "Verifying Enabled Flag Global Config after the update"); + } finally { + globalConfigurationHelper.updateGlobalConfiguration(config.getName(), + new PutGlobalConfigurationsRequest().value(config.getValue()).enabled(config.getEnabled())); } } @Test - public void testGlobalConfigForcePasswordResetDays() { - - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - + public void testPasswordUpdateFailing() { String configName = "force-password-reset-days"; - String newValue = "0"; - String newBooleanValue = "true"; - - for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(configName)) { - Integer configId = (Integer) globalConfig.get(configIndex).get("id"); - Assertions.assertNotNull(configId); - - /* - * Update force-password-reset-days with value as 0 and Enable as true - failure case - */ - ArrayList error = (ArrayList) GlobalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(this.requestSpec, - this.httpStatusForidden, configId, newValue, newBooleanValue, CommonConstants.RESPONSE_ERROR); - HashMap hash = (HashMap) error.get(0); + GlobalConfigurationPropertyData config = globalConfigurationHelper.getGlobalConfigurationByName(configName); + Assertions.assertNotNull(config); - Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero", - hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), - "Force Password Reset days value must be greater than zero."); - - /* - * Update force-password-reset-days with value as 50 and Enable as true - success case - */ - final HashMap updateSuccess = (HashMap) GlobalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration( - this.requestSpec, this.responseSpec, configId, "50", newBooleanValue, "changes"); - Assertions.assertNotNull(updateSuccess); - - /* Update with value as 0 and Enable as false - success case */ - final HashMap updateSuccess1 = (HashMap) GlobalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration( - this.requestSpec, this.responseSpec, configId, newValue, "false", "changes"); - Assertions.assertNotNull(updateSuccess1); - - /* - * Update without sending value and Enable as true - failure case - */ - ArrayList failure = (ArrayList) GlobalConfigurationHelper.updatePasswordResetDaysForGlobalConfiguration(this.requestSpec, - this.httpStatusForidden, configId, null, newBooleanValue, CommonConstants.RESPONSE_ERROR); - HashMap failureHash = (HashMap) failure.get(0); - Assertions.assertEquals("error.msg.password.reset.days.value.must.be.greater.than.zero", - failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), - "Force Password Reset days value must be greater than zero."); - - break; - } - } - /* Update other global configuration property */ - String otherConfigName = "maker-checker"; - for (Integer configIndex = 0; configIndex < globalConfig.size() - 1; configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(otherConfigName)) { - String configId = globalConfig.get(configIndex).get("id").toString(); - Integer updateConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, - configId, newValue); - Assertions.assertNotNull(updateConfigId); - break; - } - } + CallFailedRuntimeException exception = assertThrows(CallFailedRuntimeException.class, () -> globalConfigurationHelper + .updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().enabled(true).value(null))); + assertEquals(403, exception.getResponse().code()); + assertTrue(exception.getMessage().contains("error.msg.password.reset.days.value.must.be.greater.than.zero")); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountArrearsAgeingCOBBusinessStepTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountArrearsAgeingCOBBusinessStepTest.java index 5609a9ada4f..a874bf37204 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountArrearsAgeingCOBBusinessStepTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountArrearsAgeingCOBBusinessStepTest.java @@ -28,41 +28,33 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; import java.util.HashMap; import java.util.UUID; import org.apache.fineract.client.models.GetDelinquencyBucketsResponse; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdSummary; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.cob.data.JobBusinessStepConfigData; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepConfigurationHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountArrearsAgeingCOBBusinessStepTest { +public class LoanAccountArrearsAgeingCOBBusinessStepTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; - private ResponseSpecification responseSpecErr400; - private ResponseSpecification responseSpecErr503; private RequestSpecification requestSpec; private ClientHelper clientHelper; private LoanTransactionHelper loanTransactionHelper; - private DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); public static final String UPDATE_LOAN_ARREARS_AGING = "UPDATE_LOAN_ARREARS_AGING"; @BeforeEach @@ -71,8 +63,6 @@ public void setup() { this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.responseSpecErr400 = new ResponseSpecBuilder().expectStatusCode(400).build(); - this.responseSpecErr503 = new ResponseSpecBuilder().expectStatusCode(503).build(); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); } @@ -81,7 +71,7 @@ public void setup() { public void loanArrearsAgeingCOBBusinessStepTest() { // Set Business Date try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); @@ -148,7 +138,8 @@ public void loanArrearsAgeingCOBBusinessStepTest() { assertEquals(loan2Summary.getPrincipalOverdue(), 1000.00); assertEquals(loan2Summary.getTotalOverdue(), 1000.00); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountBackdatedDisbursementTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountBackdatedDisbursementTest.java index e367b68c121..4c8a210d310 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountBackdatedDisbursementTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountBackdatedDisbursementTest.java @@ -35,22 +35,19 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountBackdatedDisbursementTest { +public class LoanAccountBackdatedDisbursementTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -74,7 +71,7 @@ public void loanAccountBackDatedDisbursementForLoanProductWithEnableDownPaymentA // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -282,7 +279,8 @@ public void loanAccountBackDatedDisbursementForLoanProductWithEnableDownPaymentA assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -293,7 +291,7 @@ public void loanAccountBackDatedDisbursementForLoanProductWithEnableDownPaymentA // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -494,7 +492,8 @@ public void loanAccountBackDatedDisbursementForLoanProductWithEnableDownPaymentA assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -505,7 +504,7 @@ public void loanAccountBackDatedDisbursementAfterTwoRepaymentsForLoanProductWith // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -758,7 +757,8 @@ public void loanAccountBackDatedDisbursementAfterTwoRepaymentsForLoanProductWith assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -771,7 +771,7 @@ public void loanAccountBackDatedDisbursementWithDisbursementDateBeforeLoanSubmit // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -864,7 +864,8 @@ public void loanAccountBackDatedDisbursementWithDisbursementDateBeforeLoanSubmit loanErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -875,7 +876,7 @@ public void loanAccountBackDatedDisbursementForLoanProductWithDisableDownPayment // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -1053,7 +1054,8 @@ public void loanAccountBackDatedDisbursementForLoanProductWithDisableDownPayment assertEquals(333.34, loanDetails.getRepaymentSchedule().getPeriods().get(4).getTotalInstallmentAmountForPeriod()); assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(4).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } 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 52194eb571d..57ab3750922 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 @@ -18,9 +18,6 @@ */ package org.apache.fineract.integrationtests; -import static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; -import static org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -34,19 +31,15 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.fineract.client.models.AdvancedPaymentData; import org.apache.fineract.client.models.AllowAttributeOverrides; -import org.apache.fineract.client.models.BusinessDateRequest; import org.apache.fineract.client.models.ChargeData; 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.PaymentAllocationOrder; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; @@ -55,37 +48,30 @@ import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; -import org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.funds.FundsHelper; import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductHelper; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleProcessingType; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; -import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest { +public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest extends BaseLoanIntegrationTest { private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private ClientHelper clientHelper; private LoanTransactionHelper loanTransactionHelper; - private JournalEntryHelper journalEntryHelper; private AccountHelper accountHelper; private LoanProductHelper loanProductHelper; private PaymentTypeHelper paymentTypeHelper; @@ -145,7 +131,6 @@ public void setup() { this.writtenOff = this.accountHelper.createExpenseAccount(); this.goodwillExpenseAccount = this.accountHelper.createExpenseAccount(); - this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); } @@ -516,48 +501,4 @@ private Long createFund(final String fundJSON, final RequestSpecification reques return Long.valueOf(fundId); } - - private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) { - AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData(); - advancedPaymentData.setTransactionType("DEFAULT"); - advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule); - - List paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_PENALTY, - PaymentAllocationType.PAST_DUE_FEE, PaymentAllocationType.PAST_DUE_PRINCIPAL, PaymentAllocationType.PAST_DUE_INTEREST, - PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_PRINCIPAL, - PaymentAllocationType.DUE_INTEREST, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE, - PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST); - - advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders); - return advancedPaymentData; - } - - private List getPaymentAllocationOrder(PaymentAllocationType... paymentAllocationTypes) { - AtomicInteger integer = new AtomicInteger(1); - return Arrays.stream(paymentAllocationTypes).map(pat -> { - PaymentAllocationOrder paymentAllocationOrder = new PaymentAllocationOrder(); - paymentAllocationOrder.setPaymentAllocationRule(pat.name()); - paymentAllocationOrder.setOrder(integer.getAndIncrement()); - return paymentAllocationOrder; - }).toList(); - } - - private void runAt(String date, Runnable runnable) { - try { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 42, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, TRUE); - businessDateHelper.updateBusinessDate( - new BusinessDateRequest().type(BUSINESS_DATE.getName()).date(date).dateFormat(DATETIME_PATTERN).locale("en")); - runnable.run(); - } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, FALSE); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 42, false); - } - } - - private void updateBusinessDate(String date) { - businessDateHelper.updateBusinessDate( - new BusinessDateRequest().type(BUSINESS_DATE.getName()).date(date).dateFormat(DATETIME_PATTERN).locale("en")); - } - } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountOverpaidDateStatusTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountOverpaidDateStatusTest.java index 72f169d28f2..adea3317613 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountOverpaidDateStatusTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountOverpaidDateStatusTest.java @@ -37,22 +37,19 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountOverpaidDateStatusTest { +public class LoanAccountOverpaidDateStatusTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -75,7 +72,7 @@ public void loanOverpaidDateStatusTest() { try { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); // Loan ExternalId @@ -159,7 +156,8 @@ public void loanOverpaidDateStatusTest() { assertNotNull(loanDetailsOverpaid_3.getOverpaidOnDate()); assertEquals(loanDetailsOverpaid_3.getOverpaidOnDate(), LocalDate.of(2022, 9, 14)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest.java index 34f17cf228a..a630754a922 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest.java @@ -32,37 +32,29 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.fineract.client.models.AdvancedPaymentData; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod; import org.apache.fineract.client.models.GetLoansLoanIdResponse; -import org.apache.fineract.client.models.PaymentAllocationOrder; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; -import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest { +public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -93,7 +85,7 @@ public void loanAccountWithEnableDownPaymentAndEnableAutoRepaymentForDownPayment // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -245,7 +237,8 @@ public void loanAccountWithEnableDownPaymentAndEnableAutoRepaymentForDownPayment false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -264,7 +257,7 @@ public void loanAccountWithEnableDownPaymentAndDisableAutoRepaymentForDownPaymen // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -421,7 +414,8 @@ public void loanAccountWithEnableDownPaymentAndDisableAutoRepaymentForDownPaymen false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -438,7 +432,7 @@ public void loanAccountWithEnableDownPaymentAndDisableAutoRepaymentForDownPaymen // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -613,7 +607,8 @@ public void loanAccountWithEnableDownPaymentAndDisableAutoRepaymentForDownPaymen false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -631,7 +626,7 @@ public void loanAccountWithEnableDownPaymentWithAdvancedPaymentAllocationWithPro // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -809,7 +804,8 @@ public void loanAccountWithEnableDownPaymentWithAdvancedPaymentAllocationWithPro false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -881,31 +877,6 @@ private GetLoanProductsProductIdResponse createLoanProductWithAdvancedPaymentStr return loanTransactionHelper.getLoanProduct(loanProductId); } - private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) { - AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData(); - advancedPaymentData.setTransactionType("DEFAULT"); - advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule); - - List paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_PENALTY, - PaymentAllocationType.PAST_DUE_FEE, PaymentAllocationType.PAST_DUE_PRINCIPAL, PaymentAllocationType.PAST_DUE_INTEREST, - PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_PRINCIPAL, - PaymentAllocationType.DUE_INTEREST, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE, - PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST); - - advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders); - return advancedPaymentData; - } - - private List getPaymentAllocationOrder(PaymentAllocationType... paymentAllocationTypes) { - AtomicInteger integer = new AtomicInteger(1); - return Arrays.stream(paymentAllocationTypes).map(pat -> { - PaymentAllocationOrder paymentAllocationOrder = new PaymentAllocationOrder(); - paymentAllocationOrder.setPaymentAllocationRule(pat.name()); - paymentAllocationOrder.setOrder(integer.getAndIncrement()); - return paymentAllocationOrder; - }).toList(); - } - private void checkDownPaymentTransaction(final LocalDate transactionDate, final Float principalPortion, final Float interestPortion, final Float feePortion, final Float penaltyPortion, final Integer loanID) { ArrayList transactions = (ArrayList) loanTransactionHelper.getLoanTransactions(this.requestSpec, diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountRepaymentCalculationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountRepaymentCalculationTest.java index 63dfc7d2220..aa40d038101 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountRepaymentCalculationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountRepaymentCalculationTest.java @@ -32,21 +32,18 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccountRepaymentCalculationTest { +public class LoanAccountRepaymentCalculationTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -70,7 +67,7 @@ public void loanAccountWithEnableDownPaymentWithInstallmentsInMultipleOfNullRepa // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -151,7 +148,8 @@ public void loanAccountWithEnableDownPaymentWithInstallmentsInMultipleOfNullRepa LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -163,7 +161,7 @@ public void loanAccountWithEnableDownPaymentWithInstallmentsInMultipleOfSetAsOne // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -244,7 +242,8 @@ public void loanAccountWithEnableDownPaymentWithInstallmentsInMultipleOfSetAsOne LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -256,7 +255,7 @@ public void loanAccountWithDisableDownPaymentWithInstallmentsInMultipleOfNullRep // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -322,7 +321,8 @@ public void loanAccountWithDisableDownPaymentWithInstallmentsInMultipleOfNullRep LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -334,7 +334,7 @@ public void loanAccountWithDisableDownPaymentWithInstallmentsInMultipleOfSetAsOn // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -400,7 +400,8 @@ public void loanAccountWithDisableDownPaymentWithInstallmentsInMultipleOfSetAsOn LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountsContainsCurrencyFieldTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountsContainsCurrencyFieldTest.java index caa85a2bf02..77b7506aa3a 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountsContainsCurrencyFieldTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountsContainsCurrencyFieldTest.java @@ -29,7 +29,6 @@ import org.apache.fineract.client.models.GetClientsLoanAccounts; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; @@ -41,7 +40,7 @@ import org.slf4j.LoggerFactory; @Slf4j -public class LoanAccountsContainsCurrencyFieldTest { +public class LoanAccountsContainsCurrencyFieldTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -65,8 +64,7 @@ public void testGetClientLoanAccountsUsingExternalIdContainsCurrency() { String formattedDate = "01 September 2022"; // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -74,8 +72,7 @@ public void testGetClientLoanAccountsUsingExternalIdContainsCurrency() { final String clientExternalId = clientResponse.getResourceExternalId(); final long clientId = clientResponse.getClientId(); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); Integer loanProductId = createLoanProduct(false, NONE); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionOnChargeSubmittedDateTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionOnChargeSubmittedDateTest.java index 4ba40865e1e..d369338a216 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionOnChargeSubmittedDateTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionOnChargeSubmittedDateTest.java @@ -40,11 +40,11 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.LoanRescheduleRequestHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -60,7 +60,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class LoanAccrualTransactionOnChargeSubmittedDateTest { +public class LoanAccrualTransactionOnChargeSubmittedDateTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -98,12 +98,13 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Accrual_Accounting_Api() final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -146,7 +147,7 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Accrual_Accounting_Api() checkAccrualTransaction(currentDate, 0.0f, 10.0f, 10.0f, loanId); // Set business date - LocalDate futureDate = LocalDate.of(2023, 03, 4); + LocalDate futureDate = LocalDate.of(2023, 3, 4); final String nextAccrualRunDate = dateFormatter.format(futureDate); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, futureDate); @@ -174,8 +175,10 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Accrual_Accounting_Api() checkAccrualTransaction(futureDate, 0.0f, 10.0f, 0.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -192,12 +195,13 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Periodic_Accrual_Tra final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -241,7 +245,7 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Periodic_Accrual_Tra checkAccrualTransaction(currentDate, 0.0f, 10.0f, 10.0f, loanId); // Set business date - LocalDate futureDate = LocalDate.of(2023, 03, 4); + LocalDate futureDate = LocalDate.of(2023, 3, 4); final String nextAccrualRunDate = dateFormatter.format(futureDate); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, futureDate); @@ -269,8 +273,10 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Periodic_Accrual_Tra checkAccrualTransaction(futureDate, 0.0f, 10.0f, 0.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -286,12 +292,13 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Loan_COB_AddPeriodicAccr final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -337,7 +344,7 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Loan_COB_AddPeriodicAccr checkAccrualTransaction(currentDate, 0.0f, 10.0f, 10.0f, loanId); // Set business date - LocalDate futureDate = LocalDate.of(2023, 03, 4); + LocalDate futureDate = LocalDate.of(2023, 3, 4); final String nextAccrualRunDate = dateFormatter.format(futureDate); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, futureDate); @@ -366,8 +373,10 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Loan_COB_AddPeriodicAccr checkAccrualTransaction(futureDate, 0.0f, 10.0f, 0.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -383,12 +392,13 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Accrual_Transactions final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -432,7 +442,7 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Accrual_Transactions checkAccrualTransaction(currentDate, 0.0f, 10.0f, 10.0f, loanId); // Set business date - LocalDate futureDate = LocalDate.of(2023, 03, 4); + LocalDate futureDate = LocalDate.of(2023, 3, 4); final String nextAccrualRunDate = dateFormatter.format(futureDate); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, futureDate); @@ -460,8 +470,10 @@ public void loanAccrualTransactionOnChargeSubmittedTest_Add_Accrual_Transactions checkAccrualTransaction(futureDate, 0.0f, 10.0f, 0.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -477,12 +489,13 @@ public void loanAccrualTransactionOnChargeSubmitted_With_Multiple_Repayments_Tes final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -529,8 +542,10 @@ public void loanAccrualTransactionOnChargeSubmitted_With_Multiple_Repayments_Tes checkAccrualTransactionsForMultipleRepaymentSchedulesChargeDueDate(currentDate, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -546,11 +561,12 @@ public void loanAccrualTransactionOnChargeSubmitted_multiple_disbursement_revers final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 03, 3); + LocalDate currentDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -588,7 +604,7 @@ public void loanAccrualTransactionOnChargeSubmitted_multiple_disbursement_revers checkAccrualTransaction(currentDate, 0.0f, 0.0f, 10.0f, loanId); // Set business date - LocalDate futureDate = LocalDate.of(2023, 03, 4); + LocalDate futureDate = LocalDate.of(2023, 3, 4); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, futureDate); @@ -599,8 +615,10 @@ public void loanAccrualTransactionOnChargeSubmitted_multiple_disbursement_revers checkAccrualTransaction(currentDate, 0.0f, 0.0f, 10.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -617,9 +635,10 @@ public void loanAccrualTransaction_ChargeSubmittedDate_AdjustRepaymentScheduleSn // Set business date LocalDate currentDate = LocalDate.of(2023, 05, 19); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -721,8 +740,10 @@ public void loanAccrualTransaction_ChargeSubmittedDate_AdjustRepaymentScheduleSn verifyPeriodDates(periods); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionReversalTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionReversalTest.java index f2d985d2c5a..12af3dce07f 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionReversalTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionReversalTest.java @@ -37,11 +37,11 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -49,15 +49,12 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanAccrualTransactionReversalTest { +public class LoanAccrualTransactionReversalTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -142,7 +139,7 @@ public void testLastAccrualTransactionReversalRecalculationForLoanAccountWithInt LocalDate currentDate = LocalDate.of(2022, 05, 8); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); // Accounts oof periodic accrual @@ -176,7 +173,8 @@ public void testLastAccrualTransactionReversalRecalculationForLoanAccountWithInt // check previous accrual is reversed and new accrual created for same date and different amount. checkAccrualTransaction(currentDate, 0.71f, 0.0f, 0.0f, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOnDateTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOnDateTest.java index 87d6a87aaeb..d0619e928da 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOnDateTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOnDateTest.java @@ -26,8 +26,8 @@ import org.apache.fineract.client.models.PostLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.junit.jupiter.api.Test; @@ -41,7 +41,8 @@ public void accrualTransactionForInterestBearingLoan_WithoutCharges_SubmittedOnD try { // Configure Charge accrual date as submitted on date - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -102,7 +103,8 @@ public void accrualTransactionForInterestBearingLoan_WithoutCharges_SubmittedOnD transaction(500.0, "Disbursement", "26 April 2024", 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); } finally { - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } }); @@ -115,7 +117,8 @@ public void accrualTransactionForInterestBearingLoan_WithCharges_SubmittedOnDate try { // Configure Charge accrual date as submitted on date - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -200,7 +203,8 @@ public void accrualTransactionForInterestBearingLoan_WithCharges_SubmittedOnDate transaction(500.0, "Disbursement", "26 April 2024", 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); } finally { - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration("charge-accrual-date", + new PutGlobalConfigurationsRequest().stringValue("due-date")); } }); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBAccountLockCatchupInlineCOBTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBAccountLockCatchupInlineCOBTest.java index f68accb8074..7c19681f60c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBAccountLockCatchupInlineCOBTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBAccountLockCatchupInlineCOBTest.java @@ -31,11 +31,11 @@ import java.util.HashMap; import java.util.List; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; @@ -44,17 +44,14 @@ import org.apache.fineract.integrationtests.common.loans.LoanCOBCatchUpHelper; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; import org.awaitility.Awaitility; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanCOBAccountLockCatchupInlineCOBTest { +public class LoanCOBAccountLockCatchupInlineCOBTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -78,9 +75,9 @@ public void setup() { @Test public void testCatchUpInLockedInstanceLastCOBDateIsNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -126,17 +123,18 @@ public void testCatchUpInLockedInstanceLastCOBDateIsNull() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testInlineCOBInLockedInstanceLastCOBDateIsNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -181,17 +179,18 @@ public void testInlineCOBInLockedInstanceLastCOBDateIsNull() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testCatchUpInLockedInstanceLastCOBDateIsNotNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -255,17 +254,18 @@ public void testCatchUpInLockedInstanceLastCOBDateIsNotNull() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testInlineCOBInLockedInstanceLastCOBDateIsNotNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -313,17 +313,18 @@ public void testInlineCOBInLockedInstanceLastCOBDateIsNotNull() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBNoLock() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec); @@ -368,17 +369,18 @@ public void testLoanCOBNoLock() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBWithLoanAccountLockedWithInlineCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec); @@ -425,8 +427,9 @@ public void testLoanCOBWithLoanAccountLockedWithInlineCOB() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBCatchUpInstanceModeIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBCatchUpInstanceModeIntegrationTest.java index ba0a1dd46f0..5854fc9dfd4 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBCatchUpInstanceModeIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCOBCatchUpInstanceModeIntegrationTest.java @@ -27,10 +27,10 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.time.LocalDate; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanCOBCatchUpHelper; @@ -44,7 +44,7 @@ @Order(1) @ExtendWith(InstanceModeSupportExtension.class) -public class LoanCOBCatchUpInstanceModeIntegrationTest { +public class LoanCOBCatchUpInstanceModeIntegrationTest extends BaseLoanIntegrationTest { private LoanCOBCatchUpHelper loanCOBCatchUpHelper; private ResponseSpecification responseSpec; @@ -62,7 +62,7 @@ public void setup() throws InterruptedException { schedulerJobHelper = new SchedulerJobHelper(requestSpec); originalSchedulerStatus = schedulerJobHelper.getSchedulerStatus(); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); } @@ -122,7 +122,7 @@ public void testSchedulerDoesNotWorksWhenNotInBatchManagerMode() { @AfterEach public void tearDown() throws InterruptedException { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(false)); schedulerJobHelper.updateSchedulerStatus(originalSchedulerStatus); } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCatchUpIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCatchUpIntegrationTest.java index 62f5d962bab..a38c3fdc012 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCatchUpIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanCatchUpIntegrationTest.java @@ -32,12 +32,12 @@ import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BatchHelper; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanAccountLockHelper; @@ -45,7 +45,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanCOBCatchUpHelper; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.useradministration.users.UserHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; @@ -53,10 +52,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanCatchUpIntegrationTest { +public class LoanCatchUpIntegrationTest extends BaseLoanIntegrationTest { private static final String REPAYMENT_LOAN_PERMISSION = "REPAYMENT_LOAN"; private static final String READ_LOAN_PERMISSION = "READ_LOAN"; @@ -81,9 +78,9 @@ public void setup() { @Test public void testCatchUpInLockedInstance() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -146,8 +143,9 @@ public void testCatchUpInLockedInstance() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeOffAccountingTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeOffAccountingTest.java index 81462b81e57..e4c5b5e8b81 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeOffAccountingTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeOffAccountingTest.java @@ -36,11 +36,11 @@ import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoansLoanIdResponse; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -50,16 +50,13 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.system.CodeHelper; import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanChargeOffAccountingTest { +public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -690,7 +687,7 @@ public void loanAccountingTreatmentTestForCashBasedAccounting_ChargeOff() { @Test public void noIncomeRecognitionAfterChargeOff() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 9, 5)); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -785,7 +782,8 @@ public void noIncomeRecognitionAfterChargeOff() { assertTrue(loanDetails.getTransactions().get(5).getType().getRepayment()); assertEquals(6, loanDetails.getTransactions().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargePaymentWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargePaymentWithAdvancedPaymentAllocationTest.java index 5b216a346e9..e60dd392346 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargePaymentWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargePaymentWithAdvancedPaymentAllocationTest.java @@ -44,12 +44,12 @@ import org.apache.fineract.client.models.PostLoansLoanIdRequest; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; import org.apache.fineract.integrationtests.common.CommonConstants; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -58,7 +58,6 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper; @@ -71,11 +70,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) @Slf4j -public class LoanChargePaymentWithAdvancedPaymentAllocationTest { +public class LoanChargePaymentWithAdvancedPaymentAllocationTest extends BaseLoanIntegrationTest { private static final String DATETIME_PATTERN = "dd MMMM yyyy"; private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; @@ -169,7 +166,7 @@ public void feeAndPenaltyChargePaymentWithDefaultAllocationRuleTest() { final String jobName = "Transfer Fee For Loans From Savings"; final String startDate = "10 April 2022"; - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.15").dateFormat("yyyy.MM.dd").locale("en")); @@ -237,7 +234,8 @@ public void feeAndPenaltyChargePaymentWithDefaultAllocationRuleTest() { assertEquals(250.0d, loanDetails.getRepaymentSchedule().getPeriods().get(2).getTotalOutstandingForPeriod()); assertEquals(LocalDate.of(2023, 1, 16), loanDetails.getRepaymentSchedule().getPeriods().get(2).getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java index 442354da0af..6398a70cb74 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeSpecificDueDateTest.java @@ -43,10 +43,10 @@ import org.apache.fineract.client.models.PostLoansLoanIdChargesResponse; import org.apache.fineract.client.models.PostLoansLoanIdRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -55,15 +55,12 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; @Slf4j -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanChargeSpecificDueDateTest { +public class LoanChargeSpecificDueDateTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -238,7 +235,7 @@ public void testApplyLoanSpecificDueDatePenaltyWithDisbursementDate() { @Test public void testApplyAndWaiveInstallmentFee() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -311,7 +308,7 @@ public void testApplyAndWaiveInstallmentFee() { @Test public void testApplyAndWaiveInstallmentFeeAnotherDueDate() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -450,7 +447,7 @@ public void testApplyAndWaiveLoanSpecificDueDatePenaltyWithDisbursementDate() { @Test public void testApplyFeeAccrualOnClosedDate() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -576,14 +573,15 @@ public void testApplyFeeAccrualOnClosedDate() { assertEquals(transactionDate, journalEntries.get(0).getTransactionDate()); assertEquals(transactionDate, journalEntries.get(1).getTransactionDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testApplyFeeAccrualWhenLoanOverpaid() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -654,7 +652,8 @@ public void testApplyFeeAccrualWhenLoanOverpaid() { assertEquals(transactionDate, journalEntries.get(0).getTransactionDate()); assertEquals(transactionDate, journalEntries.get(1).getTransactionDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest.java index af8a098463a..f314743c65d 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest.java @@ -27,18 +27,15 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.time.LocalDate; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.fineract.client.models.AdvancedPaymentData; -import org.apache.fineract.client.models.PaymentAllocationOrder; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -47,11 +44,10 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; -import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest { +public class LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocationTest extends BaseLoanIntegrationTest { private static LoanTransactionHelper LOAN_TRANSACTION_HELPER; private static ResponseSpecification RESPONSE_SPEC; @@ -79,7 +75,7 @@ public void addingLoanChargeTypeInstallmentFeeForAdvancedPaymentAllocationGivesE // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 15); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BusinessDateType.BUSINESS_DATE, businessDate); // Accounts oof periodic accrual @@ -122,7 +118,8 @@ public void addingLoanChargeTypeInstallmentFeeForAdvancedPaymentAllocationGivesE loanChargeErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -139,31 +136,6 @@ private Integer createLoanProduct(final Account... accounts) { } - private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) { - AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData(); - advancedPaymentData.setTransactionType("DEFAULT"); - advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule); - - List paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_PENALTY, - PaymentAllocationType.PAST_DUE_FEE, PaymentAllocationType.PAST_DUE_PRINCIPAL, PaymentAllocationType.PAST_DUE_INTEREST, - PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_PRINCIPAL, - PaymentAllocationType.DUE_INTEREST, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE, - PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST); - - advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders); - return advancedPaymentData; - } - - private List getPaymentAllocationOrder(PaymentAllocationType... paymentAllocationTypes) { - AtomicInteger integer = new AtomicInteger(1); - return Arrays.stream(paymentAllocationTypes).map(pat -> { - PaymentAllocationOrder paymentAllocationOrder = new PaymentAllocationOrder(); - paymentAllocationOrder.setPaymentAllocationRule(pat.name()); - paymentAllocationOrder.setOrder(integer.getAndIncrement()); - return paymentAllocationOrder; - }).toList(); - } - private Integer createLoanAccount(final Integer clientID, final Integer loanProductID, final String externalId) { String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal("1000").withLoanTermFrequency("60") diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanDelinquencyDetailsNextPaymentDateConfigurationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanDelinquencyDetailsNextPaymentDateConfigurationTest.java index 1cdc11f1ed2..38c2e8ed09d 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanDelinquencyDetailsNextPaymentDateConfigurationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanDelinquencyDetailsNextPaymentDateConfigurationTest.java @@ -33,8 +33,8 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -48,8 +48,8 @@ public void testNextPaymentDateForUnpaidInstallmentsWithNPlusOneTest() { runAt("01 November 2023", () -> { try { // update Global configuration for next payment date - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "next-unpaid-due-date"); + globalConfigurationHelper.updateGlobalConfiguration("next-payment-due-date", + new PutGlobalConfigurationsRequest().stringValue("next-unpaid-due-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -122,8 +122,8 @@ public void testNextPaymentDateForUnpaidInstallmentsWithNPlusOneTest() { } finally { // reset global config - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "earliest-unpaid-date"); + globalConfigurationHelper.updateGlobalConfiguration("next-payment-due-date", + new PutGlobalConfigurationsRequest().stringValue("earliest-unpaid-date")); } }); @@ -134,8 +134,8 @@ public void testNextPaymentDateFor2Paid1PartiallyPaidInstallmentsWithNPlusOneTes runAt("01 November 2023", () -> { try { // update Global configuration for next payment date - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "next-unpaid-due-date"); + globalConfigurationHelper.updateGlobalConfiguration("next-payment-due-date", + new PutGlobalConfigurationsRequest().stringValue("next-unpaid-due-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -237,8 +237,8 @@ public void testNextPaymentDateFor2Paid1PartiallyPaidInstallmentsWithNPlusOneTes .dateFormat(DATETIME_PATTERN).locale("en")); } finally { // reset global config - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "earliest-unpaid-date"); + globalConfigurationHelper.updateGlobalConfiguration("next-payment-due-date", + new PutGlobalConfigurationsRequest().stringValue("earliest-unpaid-date")); } }); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanMultipleDisbursementRepaymentScheduleTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanMultipleDisbursementRepaymentScheduleTest.java index cef95ea9d9e..ca617d5f281 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanMultipleDisbursementRepaymentScheduleTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanMultipleDisbursementRepaymentScheduleTest.java @@ -39,11 +39,11 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -52,14 +52,11 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanMultipleDisbursementRepaymentScheduleTest { +public class LoanMultipleDisbursementRepaymentScheduleTest extends BaseLoanIntegrationTest { private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); private ResponseSpecification responseSpec; @@ -92,9 +89,9 @@ public void loanNoDuplicateRepaymentScheduleWithMultipleDisbursementTest() { final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); // Set business date - LocalDate currentDate = LocalDate.of(2023, 07, 7); + LocalDate currentDate = LocalDate.of(2023, 7, 7); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); // Loan ExternalId @@ -124,7 +121,7 @@ public void loanNoDuplicateRepaymentScheduleWithMultipleDisbursementTest() { // run cob - currentDate = LocalDate.of(2023, 07, 12); + currentDate = LocalDate.of(2023, 7, 12); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); @@ -136,7 +133,7 @@ public void loanNoDuplicateRepaymentScheduleWithMultipleDisbursementTest() { // make Merchant Issued Refund - currentDate = LocalDate.of(2023, 07, 21); + currentDate = LocalDate.of(2023, 7, 21); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); @@ -150,7 +147,7 @@ public void loanNoDuplicateRepaymentScheduleWithMultipleDisbursementTest() { schedulerJobHelper.executeAndAwaitJob(jobName); // make another disbursement - currentDate = LocalDate.of(2023, 07, 24); + currentDate = LocalDate.of(2023, 7, 24); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); @@ -169,7 +166,8 @@ public void loanNoDuplicateRepaymentScheduleWithMultipleDisbursementTest() { assertEquals(1, activePeriods); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanProductRepaymentStartDateConfigurationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanProductRepaymentStartDateConfigurationTest.java index 5cbf0e594e2..e77a5cbd594 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanProductRepaymentStartDateConfigurationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanProductRepaymentStartDateConfigurationTest.java @@ -32,6 +32,7 @@ import org.apache.fineract.client.models.GetDelinquencyBucketsResponse; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdResponse; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; @@ -52,6 +53,7 @@ public class LoanProductRepaymentStartDateConfigurationTest { private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; private ClientHelper clientHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +63,7 @@ public void setup() { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -126,7 +129,7 @@ public void loanAccountWithLoanProductRepaymentStartDateTypeAsSubmittedOnDateSch // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -265,7 +268,8 @@ public void loanAccountWithLoanProductRepaymentStartDateTypeAsSubmittedOnDateSch assertEquals(500.00, loanDetails.getRepaymentSchedule().getPeriods().get(4).getTotalInstallmentAmountForPeriod()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -280,7 +284,7 @@ public void loanAccountWithLoanProductRepaymentStartDateTypeAsDisbursementDateSc // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -422,7 +426,8 @@ public void loanAccountWithLoanProductRepaymentStartDateTypeAsDisbursementDateSc assertEquals(333.34, loanDetails.getRepaymentSchedule().getPeriods().get(4).getTotalInstallmentAmountForPeriod()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRepaymentScheduleWithDownPaymentTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRepaymentScheduleWithDownPaymentTest.java index 253fc7b6909..342739bf8ba 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRepaymentScheduleWithDownPaymentTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRepaymentScheduleWithDownPaymentTest.java @@ -45,13 +45,13 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdRequest; import org.apache.fineract.client.models.PutLoanProductsProductIdResponse; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -817,7 +817,7 @@ public void loanRepaymentScheduleWithMultiDisbursementProductTwoDisbursementAndT @Test public void testDelinquencyRangeOnDownPaymentInstallment() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = LocalDate.of(2022, 9, 5); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); String loanExternalIdStr = UUID.randomUUID().toString(); @@ -871,7 +871,8 @@ public void testDelinquencyRangeOnDownPaymentInstallment() { } finally { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -991,7 +992,7 @@ public void loanApplicationWithLoanProductWithEnableDownPaymentAndEnableAutoRepa // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Accounts oof periodic accrual @@ -1098,7 +1099,8 @@ public void loanApplicationWithLoanProductWithEnableDownPaymentAndEnableAutoRepa new JournalEntry(50, JournalEntry.TransactionType.DEBIT)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1110,7 +1112,7 @@ public void loanApplicationWithLoanProductWithEnableDownPaymentAndDisableAutoRep // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Accounts oof periodic accrual @@ -1165,7 +1167,8 @@ public void loanApplicationWithLoanProductWithEnableDownPaymentAndDisableAutoRep checkNoDownPaymentTransaction(loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleOnDecliningBalanceLoanTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleOnDecliningBalanceLoanTest.java index 058e1ba086a..fde4c5f7272 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleOnDecliningBalanceLoanTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleOnDecliningBalanceLoanTest.java @@ -33,26 +33,23 @@ import java.util.List; import java.util.Map; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.LoanRescheduleRequestHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanRescheduleOnDecliningBalanceLoanTest { +public class LoanRescheduleOnDecliningBalanceLoanTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(LoanRescheduleOnDecliningBalanceLoanTest.class); private ResponseSpecification responseSpec; @@ -285,14 +282,16 @@ private void disburseLoan(String disburseDate) { * enables the configuration `is-interest-to-be-recovered-first-when-greater-than-emi` **/ private void enableConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", true); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); } /** * disables the configuration `is-interest-to-be-recovered-first-when-greater-than-emi` **/ private void disableConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } @Test @@ -543,14 +542,16 @@ private void createRequiredEntitiesWithRecalculationEnabledWithPrincipalCompound * enables the configuration `is-principal-compounding-disabled-for-overdue-loans` **/ private void enablePrincipalCompoundingConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", true); + globalConfigurationHelper.updateGlobalConfiguration("is-principal-compounding-disabled-for-overdue-loans", + new PutGlobalConfigurationsRequest().enabled(true)); } /** * disables the configuration `is-principal-compounding-disabled-for-overdue-loans` **/ private void disablePrincipalCompoundingConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", false); + globalConfigurationHelper.updateGlobalConfiguration("is-principal-compounding-disabled-for-overdue-loans", + new PutGlobalConfigurationsRequest().enabled(false)); } /** diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleWithAdvancePaymentTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleWithAdvancePaymentTest.java index 0a7864a52f3..a4fa02c952b 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleWithAdvancePaymentTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanRescheduleWithAdvancePaymentTest.java @@ -31,25 +31,22 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.LoanRescheduleRequestHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.WorkingDaysHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanRescheduleWithAdvancePaymentTest { +public class LoanRescheduleWithAdvancePaymentTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(LoanRescheduleWithAdvancePaymentTest.class); private ResponseSpecification responseSpec; @@ -87,28 +84,32 @@ public void tearDown() { * enables the configuration `is-interest-to-be-recovered-first-when-greater-than-emi` **/ private void enableConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", true); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(true)); } /** * disables the configuration `is-interest-to-be-recovered-first-when-greater-than-emi` **/ private void disableConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "42", false); + globalConfigurationHelper.updateGlobalConfiguration("is-interest-to-be-recovered-first-when-greater-than-emi", + new PutGlobalConfigurationsRequest().enabled(false)); } /** * enables the configuration `is-principal-compounding-disabled-for-overdue-loans` **/ private void enablePrincipalCompoundingConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", true); + globalConfigurationHelper.updateGlobalConfiguration("is-principal-compounding-disabled-for-overdue-loans", + new PutGlobalConfigurationsRequest().enabled(true)); } /** * disables the configuration `is-principal-compounding-disabled-for-overdue-loans` **/ private void disablePrincipalCompoundingConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", false); + globalConfigurationHelper.updateGlobalConfiguration("is-principal-compounding-disabled-for-overdue-loans", + new PutGlobalConfigurationsRequest().enabled(false)); } /** diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java index 77942fa1598..38727e57b03 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java @@ -43,7 +43,6 @@ import org.apache.fineract.integrationtests.common.CenterHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.GroupHelper; import org.apache.fineract.integrationtests.common.OfficeHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -51,18 +50,15 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.organisation.StaffHelper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanReschedulingWithinCenterTest { +public class LoanReschedulingWithinCenterTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class); private RequestSpecification requestSpec; @@ -82,7 +78,7 @@ public void setup() { this.loanApplicationApprovalTest = new LoanApplicationApprovalTest(); this.generalResponseSpec = new ResponseSpecBuilder().build(); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } @SuppressWarnings("rawtypes") diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanSpecificDueDateChargeAfterMaturityTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanSpecificDueDateChargeAfterMaturityTest.java index 660f7e19b22..096869cbe33 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanSpecificDueDateChargeAfterMaturityTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanSpecificDueDateChargeAfterMaturityTest.java @@ -48,10 +48,10 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -60,7 +60,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper; import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType; @@ -68,13 +67,11 @@ import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({ "unchecked" }) -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanSpecificDueDateChargeAfterMaturityTest { +public class LoanSpecificDueDateChargeAfterMaturityTest extends BaseLoanIntegrationTest { private static final String DATETIME_PATTERN = "dd MMMM yyyy"; private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; @@ -436,7 +433,7 @@ public void reopenClosedLoan() { @Test public void addChargeAfterLoanMaturity() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("01 September 2023").dateFormat(DATETIME_PATTERN).locale("en")); @@ -508,7 +505,8 @@ public void addChargeAfterLoanMaturity() { validateRepaymentPeriod(loanDetails, 2, 0.0, 0.0, 0.0, 10.0, 0.0, 10.0, 0.0, 0.0); assertTrue(loanDetails.getStatus().getActive()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -590,13 +588,4 @@ private static void validateRepaymentPeriod(GetLoansLoanIdResponse loanDetails, assertEquals(paidInAdvance, loanDetails.getRepaymentSchedule().getPeriods().get(index).getTotalPaidInAdvanceForPeriod()); assertEquals(paidLate, loanDetails.getRepaymentSchedule().getPeriods().get(index).getTotalPaidLateForPeriod()); } - - private static void validateLoanSummaryBalances(GetLoansLoanIdResponse loanDetails, Double totalOutstanding, Double totalRepayment, - Double principalOutstanding, Double principalPaid, Double totalOverpaid) { - assertEquals(totalOutstanding, loanDetails.getSummary().getTotalOutstanding()); - assertEquals(totalRepayment, loanDetails.getSummary().getTotalRepayment()); - assertEquals(principalOutstanding, loanDetails.getSummary().getPrincipalOutstanding()); - assertEquals(principalPaid, loanDetails.getSummary().getPrincipalPaid()); - assertEquals(totalOverpaid, loanDetails.getTotalOverpaid()); - } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java index 0fb211c96eb..f2443be8b94 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java @@ -48,29 +48,26 @@ import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse; import org.apache.fineract.client.models.PaymentAllocationOrder; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; import org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Named; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @Slf4j -@ExtendWith(LoanTestLifecycleExtension.class) public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; @@ -198,7 +195,7 @@ public void applyLoanTransactionChargebackWithAmountZero(LoanProductTestBuilder @MethodSource("loanProductFactory") public void applyLoanTransactionChargebackInLongTermLoan(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = LocalDate.of(2023, 1, 20); todaysDate = businessDate; BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); @@ -251,7 +248,8 @@ public void applyLoanTransactionChargebackInLongTermLoan(LoanProductTestBuilder } finally { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -279,7 +277,7 @@ public void applyLoanTransactionChargebackOverNoRepaymentType(LoanProductTestBui @MethodSource("loanProductFactory") public void applyLoanTransactionChargebackAfterMature(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -383,7 +381,8 @@ public void applyLoanTransactionChargebackAfterMature(LoanProductTestBuilder loa getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 4, Double.valueOf("800.00")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -524,7 +523,7 @@ public void applyLoanTransactionChargebackWithLoanOverpaidToKeepAsLoanOverpaid(L @MethodSource("loanProductFactory") public void applyMultipleLoanTransactionChargeback(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); log.info("Current Business date {}", todaysDate); @@ -586,7 +585,8 @@ public void applyMultipleLoanTransactionChargeback(LoanProductTestBuilder loanPr DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 0, Double.valueOf("0.00")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReprocessForAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReprocessForAdvancedPaymentAllocationTest.java index 90b4da6e2da..f06eeb8d3e0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReprocessForAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReprocessForAdvancedPaymentAllocationTest.java @@ -31,20 +31,16 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.fineract.client.models.AdvancedPaymentData; import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse; -import org.apache.fineract.client.models.PaymentAllocationOrder; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -53,11 +49,10 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; -import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class LoanTransactionReprocessForAdvancedPaymentAllocationTest { +public class LoanTransactionReprocessForAdvancedPaymentAllocationTest extends BaseLoanIntegrationTest { private static LoanTransactionHelper LOAN_TRANSACTION_HELPER; private static ResponseSpecification RESPONSE_SPEC; @@ -83,7 +78,7 @@ public void loanTransactionReprocessForAddChargeTest() { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 15); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BusinessDateType.BUSINESS_DATE, businessDate); // Accounts oof periodic accrual @@ -164,7 +159,8 @@ public void loanTransactionReprocessForAddChargeTest() { verifyTransaction(LocalDate.of(2023, 2, 20), 50.0f, 40.0f, 0.0f, 0.0f, 10.0f, loanId, "repayment"); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -181,31 +177,6 @@ private Integer createLoanProduct(final Account... accounts) { } - private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) { - AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData(); - advancedPaymentData.setTransactionType("DEFAULT"); - advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule); - - List paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_PENALTY, - PaymentAllocationType.PAST_DUE_FEE, PaymentAllocationType.PAST_DUE_PRINCIPAL, PaymentAllocationType.PAST_DUE_INTEREST, - PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_PRINCIPAL, - PaymentAllocationType.DUE_INTEREST, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE, - PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST); - - advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders); - return advancedPaymentData; - } - - private List getPaymentAllocationOrder(PaymentAllocationType... paymentAllocationTypes) { - AtomicInteger integer = new AtomicInteger(1); - return Arrays.stream(paymentAllocationTypes).map(pat -> { - PaymentAllocationOrder paymentAllocationOrder = new PaymentAllocationOrder(); - paymentAllocationOrder.setPaymentAllocationRule(pat.name()); - paymentAllocationOrder.setOrder(integer.getAndIncrement()); - return paymentAllocationOrder; - }).toList(); - } - private Integer createLoanAccount(final Integer clientID, final Integer loanProductID, final String externalId) { String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal("1000").withLoanTermFrequency("60") diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReverseReplayTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReverseReplayTest.java index f73ff45a34b..61195054200 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReverseReplayTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionReverseReplayTest.java @@ -41,10 +41,10 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -52,16 +52,13 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.system.CodeHelper; import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class LoanTransactionReverseReplayTest { +public class LoanTransactionReverseReplayTest extends BaseLoanIntegrationTest { private static final String DATE_PATTERN = "dd MMMM yyyy"; private final BusinessDateHelper businessDateHelper = new BusinessDateHelper(); @@ -97,7 +94,7 @@ public void setup() { @Test public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesTest() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("04 October 2022").dateFormat(DATE_PATTERN).locale("en")); @@ -147,7 +144,8 @@ public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesTest( assertTrue(loansLoanIdResponse.getTransactions().get(lastTransactionIndex).getType().getAccrual()); assertEquals(10.0, loansLoanIdResponse.getTransactions().get(lastTransactionIndex).getAmount()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -160,7 +158,7 @@ public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesTest( @Test public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesScheduleDueDateTest() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("04 October 2022").dateFormat(DATE_PATTERN).locale("en")); @@ -226,14 +224,15 @@ public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesSched assertEquals(LocalDate.of(2022, 10, 11), loansLoanIdResponse.getRepaymentSchedule().getPeriods().get(lastPeriodIndex).getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void loanTransactionReverseReplayWithChargeOffAndCBR() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("04 October 2022").dateFormat(DATE_PATTERN).locale("en")); @@ -356,7 +355,8 @@ public void loanTransactionReverseReplayWithChargeOffAndCBR() { assertEquals(1, cbrExpenseJournalEntries.size()); assertEquals(1, cbrAssetJournalEntries.size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java index b3480ce59e4..2a47fb2a2cf 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.fineract.client.models.GlobalConfigurationPropertyData; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutPermissionsRequest; import org.apache.fineract.integrationtests.common.AuditHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -58,6 +58,7 @@ public class MakercheckerTest { private SavingsAccountHelper savingsAccountHelper; private static final String START_DATE_STRING = "03 June 2023"; private static final String TRANSACTION_DATE_STRING = "05 June 2023"; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -70,6 +71,7 @@ public void setup() { this.auditHelper = new AuditHelper(requestSpec, responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -82,22 +84,10 @@ public void testMakercheckerInboxList() { @Test public void testMakerCheckerOn() { - GlobalConfigurationPropertyData mcConfig = GlobalConfigurationHelper.getGlobalConfigurationByName(requestSpec, responseSpec, - "maker-checker"); - Long mcConfigId = mcConfig.getId(); - boolean mcConfigUpdate = false; - if (!Boolean.TRUE.equals(mcConfig.getEnabled())) { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, mcConfigId, true); - mcConfigUpdate = true; - } - GlobalConfigurationPropertyData sameMcConfig = GlobalConfigurationHelper.getGlobalConfigurationByName(requestSpec, responseSpec, - "enable-same-maker-checker"); - Long sameMcConfigId = mcConfig.getId(); - boolean sameMcConfigUpdate = false; - if (Boolean.TRUE.equals(sameMcConfig.getEnabled())) { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, sameMcConfigId, false); - sameMcConfigUpdate = true; - } + + globalConfigurationHelper.updateGlobalConfiguration("maker-checker", new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration("enable-same-maker-checker", + new PutGlobalConfigurationsRequest().enabled(false)); try { // client permission - maker-checker disabled @@ -190,12 +180,12 @@ public void testMakerCheckerOn() { CommonConstants.RESPONSE_RESOURCE_ID); assertNotNull(withdrawalId); } finally { - if (mcConfigUpdate) { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, mcConfigId, false); - } - if (sameMcConfigUpdate) { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, sameMcConfigId, true); - } + + globalConfigurationHelper.updateGlobalConfiguration("maker-checker", new PutGlobalConfigurationsRequest().enabled(false)); + + globalConfigurationHelper.updateGlobalConfiguration("enable-same-maker-checker", + new PutGlobalConfigurationsRequest().enabled(true)); + PutPermissionsRequest putPermissionsRequest = new PutPermissionsRequest().putPermissionsItem("WITHDRAWAL_SAVINGSACCOUNT", false); rolesHelper.updatePermissions(putPermissionsRequest); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RefundForActiveLoansWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RefundForActiveLoansWithAdvancedPaymentAllocationTest.java index 1ff910c904d..5d72087864c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RefundForActiveLoansWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RefundForActiveLoansWithAdvancedPaymentAllocationTest.java @@ -42,16 +42,15 @@ import org.apache.fineract.client.models.PostLoansLoanIdRequest; import org.apache.fineract.client.models.PostLoansRequest; import org.apache.fineract.client.models.PostLoansResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.impl.AdvancedPaymentScheduleTransactionProcessor; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleProcessingType; @@ -59,11 +58,9 @@ import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) @Slf4j -public class RefundForActiveLoansWithAdvancedPaymentAllocationTest { +public class RefundForActiveLoansWithAdvancedPaymentAllocationTest extends BaseLoanIntegrationTest { private static final String DATETIME_PATTERN = "dd MMMM yyyy"; private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern(DATETIME_PATTERN).toFormatter(); @@ -92,7 +89,7 @@ public static void setup() { @Test public void refundForActiveLoanWithDefaultPaymentAllocationProcessingVertically() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.15").dateFormat("yyyy.MM.dd").locale("en")); @@ -284,14 +281,15 @@ public void refundForActiveLoanWithDefaultPaymentAllocationProcessingVertically( assertEquals(250.0f, thirdRepaymentInstallment.getTotalOutstandingForPeriod()); assertEquals(LocalDate.of(2023, 4, 1), thirdRepaymentInstallment.getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void refundForActiveLoanWithDefaultPaymentAllocationProcessingHorizontally() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2023.02.15").dateFormat("yyyy.MM.dd").locale("en")); @@ -484,7 +482,8 @@ public void refundForActiveLoanWithDefaultPaymentAllocationProcessingHorizontall assertEquals(250.0f, thirdRepaymentInstallment.getTotalOutstandingForPeriod()); assertEquals(LocalDate.of(2023, 4, 1), thirdRepaymentInstallment.getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java index 4ae61978bf7..5616f3aa224 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountRecalculateBalanceTest.java @@ -66,6 +66,7 @@ public class SavingsAccountRecalculateBalanceTest { private SavingsProductHelper savingsProductHelper; private SchedulerJobHelper scheduleJobHelper; private PaymentTypeHelper paymentTypeHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -75,6 +76,7 @@ public void setup() { this.requestSpec.header("Fineract-Platform-TenantId", "default"); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.paymentTypeHelper = new PaymentTypeHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -224,7 +226,7 @@ private Integer createSavingsProduct(final RequestSpecification requestSpec, fin @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java index 0f4f666d59c..711719a4a5c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionDatatableIntegrationTest.java @@ -63,6 +63,7 @@ public class SavingsAccountTransactionDatatableIntegrationTest { private DatatableHelper datatableHelper; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -73,6 +74,7 @@ public void setup() { this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -244,7 +246,7 @@ private Integer createSavingsProductDailyPosting() { // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java index d643d23ff00..237ce87a5c6 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java @@ -31,7 +31,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.base.Strings; import com.google.gson.Gson; import io.restassured.builder.RequestSpecBuilder; @@ -56,6 +55,7 @@ import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.apache.fineract.batch.domain.Header; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BatchHelper; @@ -91,6 +91,7 @@ public class SavingsAccountTransactionTest { private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; private DatatableHelper datatableHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -103,13 +104,14 @@ public void setup() { this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test - public void verifySavingsTransactionSubmittedOnDateAndTransactionDate() throws JsonProcessingException { + public void verifySavingsTransactionSubmittedOnDateAndTransactionDate() { LocalDate today = Utils.getLocalDateOfTenant(); try { - enableBusinessDate(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); LocalDate depositDate = Utils.getDateAsLocalDate(depositDateString); @@ -124,7 +126,8 @@ public void verifySavingsTransactionSubmittedOnDateAndTransactionDate() throws J performSavingsTransaction(savingsId, "100", depositDate, true); performSavingsTransaction(savingsId, "50", withdrawDate, false); } finally { - enableBusinessDate(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -277,10 +280,6 @@ public void testDeadlockSavingsBatchTransactions() { log.info("\nFinished all threads"); } - private void enableBusinessDate(RequestSpecification requestSpec, ResponseSpecification responseSpec, boolean enable) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, enable); - } - private void performSavingsTransaction(Integer savingsId, String amount, LocalDate transactionDate, boolean isDeposit) { String transactionType = isDeposit ? "Deposit" : "Withdrawal"; Integer transactionId = isDeposit @@ -456,7 +455,7 @@ private void runDeadlockBatch(SavingsAccountHelper savingsHelper, Integer saving // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java index 65f9e5b012e..fac4d5d54df 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionsSearchIntegrationTest.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.stream.Collectors; import org.apache.fineract.client.models.GetSavingsAccountTransactionsPageItem; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.SavingsAccountTransactionsSearchResponse; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; @@ -76,6 +77,7 @@ public class SavingsAccountTransactionsSearchIntegrationTest { private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; private SavingsAccountHelper savingsAccountHelperValidationError; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -87,6 +89,7 @@ public void setup() { this.responseSpecForValidationError = new ResponseSpecBuilder().expectStatusCode(400).build(); this.savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec, this.responseSpecForValidationError); this.savingsProductHelper = new SavingsProductHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -167,14 +170,15 @@ public void testSavingsTransactionsSearchSubmittedDateFromTo() throws JsonProces final Integer savingsId = createSavingsAccountDailyPosting(clientID, startDate); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100", firstDepositDate, CommonConstants.RESPONSE_RESOURCE_ID); this.savingsAccountHelper.depositToSavingsAccount(savingsId, "300", secondDepositDate, CommonConstants.RESPONSE_RESOURCE_ID); this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, "100", withdrawDate, CommonConstants.RESPONSE_RESOURCE_ID); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } String submittedDate = DateUtils.format(businessDate, DEFAULT_DATE_FORMAT, DEFAULT_LOCALE); TransactionSearchRequest searchParameters = new TransactionSearchRequest() @@ -454,8 +458,8 @@ private Map buildTransactionsSearchQuery(TransactionSearchReques // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java index 16b6411e69d..851eb2f13a0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingIntegrationTest.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -59,6 +60,7 @@ public class SavingsInterestPostingIntegrationTest { private RequestSpecification requestSpec; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -68,13 +70,14 @@ public void setup() { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test public void testSavingsDailyInterestPosting() { LocalDate today = Utils.getLocalDateOfTenant(); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); // client activation, savings activation and 1st transaction date final String startDate = "01 November 2021"; @@ -102,7 +105,8 @@ public void testSavingsDailyInterestPosting() { Collectors.collectingAndThen(Collectors.toList(), list -> LocalDate.of(list.get(0), list.get(1), list.get(2)))); assertTrue(DateUtils.isEqual(submittedOnDate, today), "Submitted On Date check for Interest Posting transaction"); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -129,8 +133,8 @@ private Integer createSavingsProductDailyPosting() { // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java index 2f77b7c1ba2..89097188e67 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsInterestPostingJobIntegrationTest.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -68,6 +69,7 @@ public class SavingsInterestPostingJobIntegrationTest { private SchedulerJobHelper scheduleJobHelper; private JournalEntryHelper journalEntryHelper; private AccountHelper accountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -78,6 +80,7 @@ public void setup() { this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.scheduleJobHelper = new SchedulerJobHelper(requestSpec); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -149,7 +152,7 @@ public void testDuplicateOverdraftInterestPostingJob() { public void testSavingsDailyInterestPostingJob() { LocalDate today = Utils.getLocalDateOfTenant(); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); // client activation, savings activation and 1st transaction date final String startDate = "10 April 2022"; @@ -178,7 +181,8 @@ public void testSavingsDailyInterestPostingJob() { Collectors.collectingAndThen(Collectors.toList(), list -> LocalDate.of(list.get(0), list.get(1), list.get(2)))); assertTrue(DateUtils.isEqual(submittedOnDate, today), "Submitted On Date check for Interest Posting transaction"); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -318,8 +322,8 @@ public static Integer createSavingsProduct(final String minOpenningBalance) { // Reset configuration fields @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java index f3925d2c8c3..23e92a16388 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java @@ -22,15 +22,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.restassured.builder.RequestSpecBuilder; -import io.restassured.builder.ResponseSpecBuilder; import io.restassured.http.ContentType; import io.restassured.specification.RequestSpecification; -import io.restassured.specification.ResponseSpecification; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.jobs.service.JobName; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; @@ -47,6 +46,7 @@ public class SchedulerJobsTest { private RequestSpecification requestSpec; private SchedulerJobHelper schedulerJobHelper; private Boolean originalSchedulerStatus; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +61,7 @@ public void setup() { Boolean active = (Boolean) schedulerJob.get("active"); originalJobStatus.put(jobId, active); } + globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach @@ -135,14 +136,14 @@ public void testFlippingJobsActiveStatus() throws InterruptedException { @Test public void testTriggeringManualExecutionOfAllSchedulerJobs() { - ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); for (String jobName : schedulerJobHelper.getAllSchedulerJobNames()) { schedulerJobHelper.executeAndAwaitJob(jobName); } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java index 89f92d32d42..a5e13abc2b9 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java @@ -56,6 +56,7 @@ import org.apache.fineract.client.models.JournalEntryTransactionItem; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.PutJobsJobIDRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -124,6 +125,7 @@ public class SchedulerJobsTestResults { private DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); private BusinessDateHelper businessDateHelper; private static BusinessStepHelper businessStepHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeAll public static void beforeAll() { @@ -147,19 +149,20 @@ public void setup() { clientHelper = new ClientHelper(requestSpec, responseSpec); this.businessDateHelper = new BusinessDateHelper(); this.systemTimeZone = TimeZone.getTimeZone(Utils.TENANT_TIME_ZONE); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(requestSpec, responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(requestSpec, responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } @Test public void testApplyAnnualFeeForSavingsJobOutcome() throws InterruptedException { Integer savingsId = null; try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); LocalDate submittedDate = LocalDate.of(2022, 9, 28); String submittedDateString = "28 September 2022"; @@ -211,7 +214,8 @@ public void testApplyAnnualFeeForSavingsJobOutcome() throws InterruptedException .isEquivalentAccordingToCompareTo(expectedDueDate); } finally { savingsAccountHelper.closeSavingsAccountOnDate(savingsId, "true", "11 November 2022"); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -343,24 +347,10 @@ public void testApplyHolidaysToLoansJobOutcome() throws InterruptedException { JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(requestSpec, responseSpec); - Assertions.assertNotNull(globalConfig); - // Updating Value for reschedule-repayments-on-holidays Global // Configuration - Integer configId = (Integer) globalConfig.get(3).get("id"); - Assertions.assertNotNull(configId); - - HashMap configData = GlobalConfigurationHelper.getGlobalConfigurationById(requestSpec, responseSpec, configId.toString()); - Assertions.assertNotNull(configData); - - Boolean enabled = (Boolean) globalConfig.get(3).get("enabled"); - - if (!enabled) { - enabled = true; - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configId, enabled); - } + String configName = "reschedule-repayments-on-holidays"; + globalConfigurationHelper.updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().enabled(true)); holidayId = HolidayHelper.activateHolidays(requestSpec, responseSpec, holidayId.toString()); Assertions.assertNotNull(holidayId); @@ -457,24 +447,8 @@ public void testApplyType1HolidaysToLoansJobOutcome() throws InterruptedExceptio JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(requestSpec, responseSpec); - Assertions.assertNotNull(globalConfig); - - // Updating Value for reschedule-repayments-on-holidays Global - // Configuration - Integer configId = (Integer) globalConfig.get(3).get("id"); - Assertions.assertNotNull(configId); - - HashMap configData = GlobalConfigurationHelper.getGlobalConfigurationById(requestSpec, responseSpec, configId.toString()); - Assertions.assertNotNull(configData); - - Boolean enabled = (Boolean) globalConfig.get(3).get("enabled"); - - if (!enabled) { - enabled = true; - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configId, enabled); - } + String configName = "reschedule-repayments-on-holidays"; + globalConfigurationHelper.updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().enabled(true)); holidayId = HolidayHelper.activateHolidays(requestSpec, responseSpec, holidayId.toString()); Assertions.assertNotNull(holidayId); @@ -877,7 +851,7 @@ public void testApplyPenaltyForOverdueLoansJobOutcomeIfLoanChargedOff() throws I @Test public void testLoanCOBJobOutcome() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -937,14 +911,15 @@ public void testLoanCOBJobOutcome() { } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBJobOutcomeWhileAddingFeeOnDisbursementDate() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.COB_DATE, LocalDate.of(2020, 6, 2)); this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); @@ -1003,14 +978,15 @@ public void testLoanCOBJobOutcomeWhileAddingFeeOnDisbursementDate() { assertEquals(LocalDate.of(2020, 6, 2), journalEntries.get(1).getTransactionDate()); assertEquals(LocalDate.of(2020, 6, 2), journalEntries.get(0).getTransactionDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBRunsOnlyOnLoansOneDayBehind() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -1058,17 +1034,18 @@ public void testLoanCOBRunsOnlyOnLoansOneDayBehind() { loan = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanID); Assertions.assertEquals(LocalDate.of(2020, 7, 3), loan.getLastClosedBusinessDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBApplyPenaltyOnDue() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.COB_DATE, LocalDate.of(2019, 2, 2)); // set penalty wait period to 0 - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -1118,18 +1095,19 @@ public void testLoanCOBApplyPenaltyOnDue() { Assertions.assertEquals(4, ((List) transactions.get(2).get("date")).get(1)); Assertions.assertEquals(2, ((List) transactions.get(2).get("date")).get(2)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBApplyPenaltyOnDue1DayGracePeriod() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.COB_DATE, LocalDate.of(2020, 2, 2)); // set penalty wait period to 0 - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -1158,7 +1136,7 @@ public void testLoanCOBApplyPenaltyOnDue1DayGracePeriod() { JsonPath.from(loanDetails2).get("netDisbursalAmount").toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "1"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(1L)); LocalDate dateToFastForward = LocalDate.of(2020, 5, 2); String jobName = "Loan COB"; BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.COB_DATE, dateToFastForward); @@ -1180,8 +1158,9 @@ public void testLoanCOBApplyPenaltyOnDue1DayGracePeriod() { Assertions.assertEquals(5, ((List) transactions.get(2).get("date")).get(1)); Assertions.assertEquals(2, ((List) transactions.get(2).get("date")).get(2)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "2"); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(2L)); } } @@ -1356,7 +1335,7 @@ public void testInterestTransferForSavings() throws InterruptedException { public void businessDateIsCorrectForCronJob() throws InterruptedException { this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); businessDateHelper.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName()) .date("2022.09.04").dateFormat("yyyy.MM.dd").locale("en")); @@ -1400,7 +1379,8 @@ public void businessDateIsCorrectForCronJob() throws InterruptedException { GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId); assertEquals(LocalDate.of(2022, 9, 5), loanDetails.getTransactions().get(1).getDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); this.schedulerJobHelper.updateSchedulerJob(16L, new PutJobsJobIDRequest().cronExpression("0 2 0 1/1 * ? *")); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java index 36a3d551b4f..a151dfbfe87 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java @@ -30,6 +30,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsResponse; import org.apache.fineract.integrationtests.common.CalendarHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; @@ -58,7 +60,6 @@ public class SkipRepaymentOnMonthFirstTest { private RequestSpecification requestSpec; private GlobalConfigurationHelper globalConfigurationHelper; private LoanTransactionHelper loanTransactionHelper; - private CalendarHelper calendarHelper; @BeforeEach public void setup() { @@ -66,39 +67,26 @@ public void setup() { this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + globalConfigurationHelper.resetAllDefaultGlobalConfigurations(); + globalConfigurationHelper.verifyAllDefaultGlobalConfigurations(); } - @Test public void testSkippingRepaymentOnFirstDayOfMonth() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - String configName = "skip-repayment-on-first-day-of-month"; boolean newBooleanValue = true; - - for (Integer configIndex = 0; configIndex < globalConfig.size(); configIndex++) { - if (globalConfig.get(configIndex).get("name").equals(configName)) { - String configId = globalConfig.get(configIndex).get("id").toString(); - Integer updateConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, - this.responseSpec, configId.toString(), newBooleanValue); - Assertions.assertNotNull(updateConfigId); - break; - } - } - + PutGlobalConfigurationsResponse response = globalConfigurationHelper.updateGlobalConfiguration(configName, + new PutGlobalConfigurationsRequest().enabled(newBooleanValue)); + Assertions.assertNotNull(response); } @Test public void checkRepaymentSkipOnFirstDayOfMonth() { + testSkippingRepaymentOnFirstDayOfMonth(); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); 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 ad982b23b51..20130f21a16 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 @@ -32,10 +32,8 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.fineract.client.models.AdvancedPaymentData; import org.apache.fineract.client.models.AllowAttributeOverrides; import org.apache.fineract.client.models.ChargeData; @@ -44,17 +42,16 @@ 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.PaymentAllocationOrder; 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; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -64,19 +61,15 @@ import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductHelper; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleProcessingType; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; -import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -@ExtendWith(LoanTestLifecycleExtension.class) -public class UndoRepaymentWithDownPaymentIntegrationTest { +public class UndoRepaymentWithDownPaymentIntegrationTest extends BaseLoanIntegrationTest { private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); private ResponseSpecification responseSpec; @@ -147,7 +140,7 @@ public void setup() { @Test public void undoRepaymentWithDownPaymentAndAdvancedPaymentAllocationTest() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); String loanExternalIdStr = UUID.randomUUID().toString(); @@ -365,29 +358,4 @@ private Long createFund(final String fundJSON, final RequestSpecification reques return Long.valueOf(fundId); } - - private AdvancedPaymentData createDefaultPaymentAllocation(String futureInstallmentAllocationRule) { - AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData(); - advancedPaymentData.setTransactionType("DEFAULT"); - advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule); - - List paymentAllocationOrders = getPaymentAllocationOrder(PaymentAllocationType.PAST_DUE_PENALTY, - PaymentAllocationType.PAST_DUE_FEE, PaymentAllocationType.PAST_DUE_PRINCIPAL, PaymentAllocationType.PAST_DUE_INTEREST, - PaymentAllocationType.DUE_PENALTY, PaymentAllocationType.DUE_FEE, PaymentAllocationType.DUE_PRINCIPAL, - PaymentAllocationType.DUE_INTEREST, PaymentAllocationType.IN_ADVANCE_PENALTY, PaymentAllocationType.IN_ADVANCE_FEE, - PaymentAllocationType.IN_ADVANCE_PRINCIPAL, PaymentAllocationType.IN_ADVANCE_INTEREST); - - advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrders); - return advancedPaymentData; - } - - private List getPaymentAllocationOrder(PaymentAllocationType... paymentAllocationTypes) { - AtomicInteger integer = new AtomicInteger(1); - return Arrays.stream(paymentAllocationTypes).map(pat -> { - PaymentAllocationOrder paymentAllocationOrder = new PaymentAllocationOrder(); - paymentAllocationOrder.setPaymentAllocationRule(pat.name()); - paymentAllocationOrder.setOrder(integer.getAndIncrement()); - return paymentAllocationOrder; - }).toList(); - } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/cob/CobPartitioningTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/cob/CobPartitioningTest.java index 084c9e4b3f6..c1e3c068645 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/cob/CobPartitioningTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/cob/CobPartitioningTest.java @@ -42,11 +42,12 @@ import org.apache.fineract.accounting.common.AccountingConstants; import org.apache.fineract.client.models.GetFinancialActivityAccountsResponse; import org.apache.fineract.client.models.PostFinancialActivityAccountsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.integrationtests.BaseLoanIntegrationTest; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -56,18 +57,15 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; @SuppressWarnings("rawtypes") @Slf4j -@ExtendWith(LoanTestLifecycleExtension.class) -public class CobPartitioningTest { +public class CobPartitioningTest extends BaseLoanIntegrationTest { public static final int N = 10; private static ResponseSpecification RESPONSE_SPEC; @@ -119,8 +117,7 @@ private static void setProperFinancialActivity(Account transferAccount) { public void testLoanCOBPartitioningQuery() throws InterruptedException { try { ExecutorService executorService = Executors.newFixedThreadPool(10); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); List loanIds = new CopyOnWriteArrayList<>(); @@ -192,9 +189,9 @@ private static void waitForFutures(List> futures, CountDownLatch creat } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, LocalDate.parse(date)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); } private void cleanUpAndRestoreBusinessDate() { @@ -203,9 +200,8 @@ private void cleanUpAndRestoreBusinessDate() { REQUEST_SPEC.header("Fineract-Platform-TenantId", "default"); RESPONSE_SPEC = new ResponseSpecBuilder().expectStatusCode(200).build(); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, TODAYS_DATE); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @NotNull diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java index 98049242c15..4be77f8c8d7 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java @@ -22,63 +22,47 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import com.google.gson.Gson; -import io.restassured.specification.RequestSpecification; -import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.client.models.GetGlobalConfigurationsResponse; import org.apache.fineract.client.models.GlobalConfigurationPropertyData; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsResponse; import org.apache.fineract.client.util.JSON; +import org.apache.fineract.integrationtests.client.IntegrationTest; import org.junit.jupiter.api.Assertions; @SuppressWarnings({ "unused", "rawtypes" }) @Slf4j @RequiredArgsConstructor -public class GlobalConfigurationHelper { +public class GlobalConfigurationHelper extends IntegrationTest { private static final Gson GSON = new JSON().getGson(); - private final RequestSpecification requestSpec; - private final ResponseSpecification responseSpec; public static final String ENABLE_AUTOGENERATED_EXTERNAL_ID = "enable-auto-generated-external-id"; - public static ArrayList getAllGlobalConfigurations(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { - final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER; + public GetGlobalConfigurationsResponse getAllGlobalConfigurations() { log.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); - final HashMap> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, - ""); - return response.get("globalConfiguration"); + return ok(fineract().globalConfigurations.retrieveConfiguration(false)); } - public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String configId) { - final String GET_GLOBAL_CONFIG_BY_ID_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); - return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, ""); - } - - public static GlobalConfigurationPropertyData getGlobalConfigurationByName(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String name) { - final String GET_GLOBAL_CONFIG_BY_NAME_URL = "/fineract-provider/api/v1/configurations/name/" + name + "?" - + Utils.TENANT_IDENTIFIER; + public GlobalConfigurationPropertyData getGlobalConfigurationByName(final String configName) { log.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY NAME -------------------------"); - String response = Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_NAME_URL); - return GSON.fromJson(response, GlobalConfigurationPropertyData.class); + return ok(fineract().globalConfigurations.retrieveOneByName(configName)); } // TODO: This is quite a bad pattern and adds a lot of time to individual test executions - public static void resetAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { + public void resetAllDefaultGlobalConfigurations() { - ArrayList actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec); + GetGlobalConfigurationsResponse actualGlobalConfigurations = getAllGlobalConfigurations(); final ArrayList defaults = getAllDefaultGlobalConfigurations(); int changedNo = 0; - for (int i = 0; i < actualGlobalConfigurations.size(); i++) { + for (int i = 0; i < actualGlobalConfigurations.getGlobalConfiguration().size(); i++) { HashMap defaultGlobalConfiguration = defaults.get(i); - HashMap actualGlobalConfiguration = actualGlobalConfigurations.get(i); + GlobalConfigurationPropertyData actualGlobalConfiguration = actualGlobalConfigurations.getGlobalConfiguration().get(i); if (!isMatching(defaultGlobalConfiguration, actualGlobalConfiguration)) { @@ -95,12 +79,11 @@ public static void resetAllDefaultGlobalConfigurations(final RequestSpecificatio // integration test suite. // If any other column is modified by the integration test suite in // the future, it needs to be reset here. - final Integer configDefaultId = (Integer) defaultGlobalConfiguration.get("id"); - final String configDefaultValue = String.valueOf(defaultGlobalConfiguration.get("value")); + final String configName = (String) defaultGlobalConfiguration.get("name"); + final Long configDefaultValue = (Long) defaultGlobalConfiguration.get("value"); - updateValueForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), configDefaultValue); - updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configDefaultId.toString(), - (Boolean) defaultGlobalConfiguration.get("enabled")); + updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().value(configDefaultValue) + .enabled((Boolean) defaultGlobalConfiguration.get("enabled"))); changedNo++; } } @@ -108,33 +91,30 @@ public static void resetAllDefaultGlobalConfigurations(final RequestSpecificatio changedNo); } - private static boolean isMatching(HashMap o1, HashMap o2) { - return o1.get("id").equals(o2.get("id")) && o1.get("name").equals(o2.get("name")) && o1.get("value").equals(o2.get("value")) - && o1.get("enabled").equals(o2.get("enabled")) && o1.get("trapDoor").equals(o2.get("trapDoor")); + private static boolean isMatching(HashMap o1, GlobalConfigurationPropertyData o2) { + return o1.get("name").equals(o2.getName()) && o1.get("value").equals(o2.getValue()) && o1.get("enabled").equals(o2.getEnabled()) + && o1.get("trapDoor").equals(o2.getTrapDoor()); } - public static void verifyAllDefaultGlobalConfigurations(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { + public void verifyAllDefaultGlobalConfigurations() { ArrayList expectedGlobalConfigurations = getAllDefaultGlobalConfigurations(); - ArrayList actualGlobalConfigurations = getAllGlobalConfigurations(requestSpec, responseSpec); + GetGlobalConfigurationsResponse actualGlobalConfigurations = getAllGlobalConfigurations(); Assertions.assertEquals(55, expectedGlobalConfigurations.size()); - Assertions.assertEquals(55, actualGlobalConfigurations.size()); + Assertions.assertEquals(55, actualGlobalConfigurations.getGlobalConfiguration().size()); for (int i = 0; i < expectedGlobalConfigurations.size(); i++) { HashMap expectedGlobalConfiguration = expectedGlobalConfigurations.get(i); - HashMap actualGlobalConfiguration = actualGlobalConfigurations.get(i); + GlobalConfigurationPropertyData actualGlobalConfiguration = actualGlobalConfigurations.getGlobalConfiguration().get(i); - Assertions.assertEquals(expectedGlobalConfiguration.get("id"), actualGlobalConfiguration.get("id")); - final String assertionFailedMessage = "Assertion failed for configID:<" + expectedGlobalConfiguration.get("id") + ">"; - Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.get("name"), assertionFailedMessage); - Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.get("value"), - assertionFailedMessage); - Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.get("enabled"), + final String assertionFailedMessage = "Assertion failed for configName:<" + expectedGlobalConfiguration.get("name") + ">"; + Assertions.assertEquals(expectedGlobalConfiguration.get("name"), actualGlobalConfiguration.getName(), assertionFailedMessage); + Assertions.assertEquals(expectedGlobalConfiguration.get("value"), actualGlobalConfiguration.getValue(), assertionFailedMessage); + Assertions.assertEquals(expectedGlobalConfiguration.get("enabled"), actualGlobalConfiguration.getEnabled(), assertionFailedMessage); - Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"), + Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.getTrapDoor(), assertionFailedMessage); } } @@ -153,25 +133,22 @@ private static ArrayList getAllDefaultGlobalConfigurations() { ArrayList defaults = new ArrayList<>(); HashMap makerCheckerDefault = new HashMap<>(); - makerCheckerDefault.put("id", 1); makerCheckerDefault.put("name", "maker-checker"); - makerCheckerDefault.put("value", 0); + makerCheckerDefault.put("value", 0L); makerCheckerDefault.put("enabled", false); makerCheckerDefault.put("trapDoor", false); defaults.add(makerCheckerDefault); HashMap amazonS3Default = new HashMap<>(); - amazonS3Default.put("id", 4); amazonS3Default.put("name", "amazon-S3"); - amazonS3Default.put("value", 0); + amazonS3Default.put("value", 0L); amazonS3Default.put("enabled", false); amazonS3Default.put("trapDoor", false); defaults.add(amazonS3Default); HashMap rescheduleFuturePaymentsDefault = new HashMap<>(); - rescheduleFuturePaymentsDefault.put("id", 5); rescheduleFuturePaymentsDefault.put("name", "reschedule-future-repayments"); - rescheduleFuturePaymentsDefault.put("value", 0); + rescheduleFuturePaymentsDefault.put("value", 0L); rescheduleFuturePaymentsDefault.put("enabled", true); rescheduleFuturePaymentsDefault.put("trapDoor", false); defaults.add(rescheduleFuturePaymentsDefault); @@ -179,421 +156,370 @@ private static ArrayList getAllDefaultGlobalConfigurations() { HashMap rescheduleRepaymentsOnHolidaysDefault = new HashMap<>(); rescheduleRepaymentsOnHolidaysDefault.put("id", 6); rescheduleRepaymentsOnHolidaysDefault.put("name", "reschedule-repayments-on-holidays"); - rescheduleRepaymentsOnHolidaysDefault.put("value", 0); + rescheduleRepaymentsOnHolidaysDefault.put("value", 0L); rescheduleRepaymentsOnHolidaysDefault.put("enabled", false); rescheduleRepaymentsOnHolidaysDefault.put("trapDoor", false); defaults.add(rescheduleRepaymentsOnHolidaysDefault); HashMap allowTransactionsOnHolidayDefault = new HashMap<>(); - allowTransactionsOnHolidayDefault.put("id", 7); allowTransactionsOnHolidayDefault.put("name", "allow-transactions-on-holiday"); - allowTransactionsOnHolidayDefault.put("value", 0); + allowTransactionsOnHolidayDefault.put("value", 0L); allowTransactionsOnHolidayDefault.put("enabled", false); allowTransactionsOnHolidayDefault.put("trapDoor", false); defaults.add(allowTransactionsOnHolidayDefault); HashMap allowTransactionsOnNonWorkingDayDefault = new HashMap<>(); - allowTransactionsOnNonWorkingDayDefault.put("id", 8); allowTransactionsOnNonWorkingDayDefault.put("name", "allow-transactions-on-non_workingday"); - allowTransactionsOnNonWorkingDayDefault.put("value", 0); + allowTransactionsOnNonWorkingDayDefault.put("value", 0L); allowTransactionsOnNonWorkingDayDefault.put("enabled", false); allowTransactionsOnNonWorkingDayDefault.put("trapDoor", false); defaults.add(allowTransactionsOnNonWorkingDayDefault); HashMap constraintApproachForDataTablesDefault = new HashMap<>(); - constraintApproachForDataTablesDefault.put("id", 9); constraintApproachForDataTablesDefault.put("name", "constraint_approach_for_datatables"); - constraintApproachForDataTablesDefault.put("value", 0); + constraintApproachForDataTablesDefault.put("value", 0L); constraintApproachForDataTablesDefault.put("enabled", false); constraintApproachForDataTablesDefault.put("trapDoor", false); defaults.add(constraintApproachForDataTablesDefault); HashMap penaltyWaitPeriodDefault = new HashMap<>(); - penaltyWaitPeriodDefault.put("id", 10); penaltyWaitPeriodDefault.put("name", "penalty-wait-period"); - penaltyWaitPeriodDefault.put("value", 2); + penaltyWaitPeriodDefault.put("value", 2L); penaltyWaitPeriodDefault.put("enabled", true); penaltyWaitPeriodDefault.put("trapDoor", false); defaults.add(penaltyWaitPeriodDefault); HashMap forcePasswordResetDaysDefault = new HashMap<>(); - forcePasswordResetDaysDefault.put("id", 11); forcePasswordResetDaysDefault.put("name", "force-password-reset-days"); - forcePasswordResetDaysDefault.put("value", 0); + forcePasswordResetDaysDefault.put("value", 0L); forcePasswordResetDaysDefault.put("enabled", false); forcePasswordResetDaysDefault.put("trapDoor", false); defaults.add(forcePasswordResetDaysDefault); HashMap graceOnPenaltyPostingDefault = new HashMap<>(); - graceOnPenaltyPostingDefault.put("id", 12); graceOnPenaltyPostingDefault.put("name", "grace-on-penalty-posting"); - graceOnPenaltyPostingDefault.put("value", 0); + graceOnPenaltyPostingDefault.put("value", 0L); graceOnPenaltyPostingDefault.put("enabled", true); graceOnPenaltyPostingDefault.put("trapDoor", false); defaults.add(graceOnPenaltyPostingDefault); HashMap savingsInterestPostingCurrentPeriodEndDefault = new HashMap<>(); - savingsInterestPostingCurrentPeriodEndDefault.put("id", 15); savingsInterestPostingCurrentPeriodEndDefault.put("name", "savings-interest-posting-current-period-end"); - savingsInterestPostingCurrentPeriodEndDefault.put("value", 0); + savingsInterestPostingCurrentPeriodEndDefault.put("value", 0L); savingsInterestPostingCurrentPeriodEndDefault.put("enabled", false); savingsInterestPostingCurrentPeriodEndDefault.put("trapDoor", false); defaults.add(savingsInterestPostingCurrentPeriodEndDefault); HashMap financialYearBeginningMonthDefault = new HashMap<>(); - financialYearBeginningMonthDefault.put("id", 16); financialYearBeginningMonthDefault.put("name", "financial-year-beginning-month"); - financialYearBeginningMonthDefault.put("value", 1); + financialYearBeginningMonthDefault.put("value", 1L); financialYearBeginningMonthDefault.put("enabled", true); financialYearBeginningMonthDefault.put("trapDoor", false); defaults.add(financialYearBeginningMonthDefault); HashMap minClientsInGroupDefault = new HashMap<>(); - minClientsInGroupDefault.put("id", 17); minClientsInGroupDefault.put("name", "min-clients-in-group"); - minClientsInGroupDefault.put("value", 5); + minClientsInGroupDefault.put("value", 5L); minClientsInGroupDefault.put("enabled", false); minClientsInGroupDefault.put("trapDoor", false); defaults.add(minClientsInGroupDefault); HashMap maxClientsInGroupDefault = new HashMap<>(); - maxClientsInGroupDefault.put("id", 18); maxClientsInGroupDefault.put("name", "max-clients-in-group"); - maxClientsInGroupDefault.put("value", 5); + maxClientsInGroupDefault.put("value", 5L); maxClientsInGroupDefault.put("enabled", false); maxClientsInGroupDefault.put("trapDoor", false); defaults.add(maxClientsInGroupDefault); HashMap meetingsMandatoryForJlgLoansDefault = new HashMap<>(); - meetingsMandatoryForJlgLoansDefault.put("id", 19); meetingsMandatoryForJlgLoansDefault.put("name", "meetings-mandatory-for-jlg-loans"); - meetingsMandatoryForJlgLoansDefault.put("value", 0); + meetingsMandatoryForJlgLoansDefault.put("value", 0L); meetingsMandatoryForJlgLoansDefault.put("enabled", false); meetingsMandatoryForJlgLoansDefault.put("trapDoor", false); defaults.add(meetingsMandatoryForJlgLoansDefault); HashMap officeSpecificProductsEnabledDefault = new HashMap<>(); - officeSpecificProductsEnabledDefault.put("id", 20); officeSpecificProductsEnabledDefault.put("name", "office-specific-products-enabled"); - officeSpecificProductsEnabledDefault.put("value", 0); + officeSpecificProductsEnabledDefault.put("value", 0L); officeSpecificProductsEnabledDefault.put("enabled", false); officeSpecificProductsEnabledDefault.put("trapDoor", false); defaults.add(officeSpecificProductsEnabledDefault); HashMap restrictProductsToUserOfficeDefault = new HashMap<>(); - restrictProductsToUserOfficeDefault.put("id", 21); restrictProductsToUserOfficeDefault.put("name", "restrict-products-to-user-office"); - restrictProductsToUserOfficeDefault.put("value", 0); + restrictProductsToUserOfficeDefault.put("value", 0L); restrictProductsToUserOfficeDefault.put("enabled", false); restrictProductsToUserOfficeDefault.put("trapDoor", false); defaults.add(restrictProductsToUserOfficeDefault); HashMap officeOpeningBalancesContraAccountDefault = new HashMap<>(); - officeOpeningBalancesContraAccountDefault.put("id", 22); officeOpeningBalancesContraAccountDefault.put("name", "office-opening-balances-contra-account"); - officeOpeningBalancesContraAccountDefault.put("value", 0); + officeOpeningBalancesContraAccountDefault.put("value", 0L); officeOpeningBalancesContraAccountDefault.put("enabled", true); officeOpeningBalancesContraAccountDefault.put("trapDoor", false); defaults.add(officeOpeningBalancesContraAccountDefault); HashMap roundingModeDefault = new HashMap<>(); - roundingModeDefault.put("id", 23); roundingModeDefault.put("name", "rounding-mode"); - roundingModeDefault.put("value", 6); + roundingModeDefault.put("value", 6L); roundingModeDefault.put("enabled", true); roundingModeDefault.put("trapDoor", true); defaults.add(roundingModeDefault); HashMap backDatePenaltiesEnabledDefault = new HashMap<>(); - backDatePenaltiesEnabledDefault.put("id", 24); backDatePenaltiesEnabledDefault.put("name", "backdate-penalties-enabled"); - backDatePenaltiesEnabledDefault.put("value", 0); + backDatePenaltiesEnabledDefault.put("value", 0L); backDatePenaltiesEnabledDefault.put("enabled", true); backDatePenaltiesEnabledDefault.put("trapDoor", false); defaults.add(backDatePenaltiesEnabledDefault); HashMap organisationStartDateDefault = new HashMap<>(); - organisationStartDateDefault.put("id", 25); organisationStartDateDefault.put("name", "organisation-start-date"); - organisationStartDateDefault.put("value", 0); + organisationStartDateDefault.put("value", 0L); organisationStartDateDefault.put("enabled", false); organisationStartDateDefault.put("trapDoor", false); defaults.add(organisationStartDateDefault); HashMap paymentTypeApplicableForDisbursementChargesDefault = new HashMap<>(); - paymentTypeApplicableForDisbursementChargesDefault.put("id", 26); paymentTypeApplicableForDisbursementChargesDefault.put("name", "paymenttype-applicable-for-disbursement-charges"); - paymentTypeApplicableForDisbursementChargesDefault.put("value", 0); + paymentTypeApplicableForDisbursementChargesDefault.put("value", 0L); paymentTypeApplicableForDisbursementChargesDefault.put("enabled", false); paymentTypeApplicableForDisbursementChargesDefault.put("trapDoor", false); defaults.add(paymentTypeApplicableForDisbursementChargesDefault); HashMap interestChargedFromDateSameAsDisbursalDateDefault = new HashMap<>(); - interestChargedFromDateSameAsDisbursalDateDefault.put("id", 27); interestChargedFromDateSameAsDisbursalDateDefault.put("name", "interest-charged-from-date-same-as-disbursal-date"); - interestChargedFromDateSameAsDisbursalDateDefault.put("value", 0); + interestChargedFromDateSameAsDisbursalDateDefault.put("value", 0L); interestChargedFromDateSameAsDisbursalDateDefault.put("enabled", false); interestChargedFromDateSameAsDisbursalDateDefault.put("trapDoor", false); defaults.add(interestChargedFromDateSameAsDisbursalDateDefault); HashMap skipRepaymentOnFirstDayOfMonthDefault = new HashMap<>(); - skipRepaymentOnFirstDayOfMonthDefault.put("id", 28); skipRepaymentOnFirstDayOfMonthDefault.put("name", "skip-repayment-on-first-day-of-month"); - skipRepaymentOnFirstDayOfMonthDefault.put("value", 14); + skipRepaymentOnFirstDayOfMonthDefault.put("value", 14L); skipRepaymentOnFirstDayOfMonthDefault.put("enabled", false); skipRepaymentOnFirstDayOfMonthDefault.put("trapDoor", false); defaults.add(skipRepaymentOnFirstDayOfMonthDefault); HashMap changeEmiIfRepaymentDateSameAsDisbursementDateDefault = new HashMap<>(); - changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("id", 29); changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("name", "change-emi-if-repaymentdate-same-as-disbursementdate"); - changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("value", 0); + changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("value", 0L); changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("enabled", true); changeEmiIfRepaymentDateSameAsDisbursementDateDefault.put("trapDoor", false); defaults.add(changeEmiIfRepaymentDateSameAsDisbursementDateDefault); HashMap dailyTptLimitDefault = new HashMap<>(); - dailyTptLimitDefault.put("id", 30); dailyTptLimitDefault.put("name", "daily-tpt-limit"); - dailyTptLimitDefault.put("value", 0); + dailyTptLimitDefault.put("value", 0L); dailyTptLimitDefault.put("enabled", false); dailyTptLimitDefault.put("trapDoor", false); defaults.add(dailyTptLimitDefault); HashMap enableAddressDefault = new HashMap<>(); - enableAddressDefault.put("id", 31); enableAddressDefault.put("name", "Enable-Address"); - enableAddressDefault.put("value", 0); + enableAddressDefault.put("value", 0L); enableAddressDefault.put("enabled", false); enableAddressDefault.put("trapDoor", false); defaults.add(enableAddressDefault); HashMap enableSubRatesDefault = new HashMap<>(); - enableSubRatesDefault.put("id", 32); enableSubRatesDefault.put("name", "sub-rates"); - enableSubRatesDefault.put("value", 0); + enableSubRatesDefault.put("value", 0L); enableSubRatesDefault.put("enabled", false); enableSubRatesDefault.put("trapDoor", false); defaults.add(enableSubRatesDefault); HashMap isFirstPaydayAllowedOnHoliday = new HashMap<>(); - isFirstPaydayAllowedOnHoliday.put("id", 33); isFirstPaydayAllowedOnHoliday.put("name", "loan-reschedule-is-first-payday-allowed-on-holiday"); - isFirstPaydayAllowedOnHoliday.put("value", 0); + isFirstPaydayAllowedOnHoliday.put("value", 0L); isFirstPaydayAllowedOnHoliday.put("enabled", false); isFirstPaydayAllowedOnHoliday.put("trapDoor", false); defaults.add(isFirstPaydayAllowedOnHoliday); HashMap isAccountMappedForPayment = new HashMap<>(); - isAccountMappedForPayment.put("id", 35); isAccountMappedForPayment.put("name", "account-mapping-for-payment-type"); - isAccountMappedForPayment.put("value", 0); + isAccountMappedForPayment.put("value", 0L); isAccountMappedForPayment.put("enabled", true); isAccountMappedForPayment.put("trapDoor", false); isAccountMappedForPayment.put("string_value", "Asset"); defaults.add(isAccountMappedForPayment); HashMap isAccountMappedForCharge = new HashMap<>(); - isAccountMappedForCharge.put("id", 36); isAccountMappedForCharge.put("name", "account-mapping-for-charge"); - isAccountMappedForCharge.put("value", 0); + isAccountMappedForCharge.put("value", 0L); isAccountMappedForCharge.put("enabled", true); isAccountMappedForCharge.put("trapDoor", false); isAccountMappedForCharge.put("string_value", "Income"); defaults.add(isAccountMappedForCharge); HashMap isNextDayFixedDepositInterestTransferEnabledForPeriodEnd = new HashMap<>(); - isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("id", 37); isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("name", "fixed-deposit-transfer-interest-next-day-for-period-end-posting"); - isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("value", 0); + isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("value", 0L); isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("enabled", false); isNextDayFixedDepositInterestTransferEnabledForPeriodEnd.put("trapDoor", false); defaults.add(isNextDayFixedDepositInterestTransferEnabledForPeriodEnd); HashMap isAllowedBackDatedTransactionsBeforeInterestPostingDate = new HashMap<>(); - isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("id", 38); isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("name", "allow-backdated-transaction-before-interest-posting"); - isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("value", 0); + isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("value", 0L); isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("enabled", true); isAllowedBackDatedTransactionsBeforeInterestPostingDate.put("trapDoor", false); defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDate); HashMap isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays = new HashMap<>(); - isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("id", 39); isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("name", "allow-backdated-transaction-before-interest-posting-date-for-days"); - isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("value", 0); + isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("value", 0L); isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("enabled", false); isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays.put("trapDoor", false); defaults.add(isAllowedBackDatedTransactionsBeforeInterestPostingDateForDays); HashMap isClientAccountNumberLengthModify = new HashMap<>(); - isClientAccountNumberLengthModify.put("id", 40); isClientAccountNumberLengthModify.put("name", "custom-account-number-length"); - isClientAccountNumberLengthModify.put("value", 0); + isClientAccountNumberLengthModify.put("value", 0L); isClientAccountNumberLengthModify.put("enabled", false); isClientAccountNumberLengthModify.put("trapDoor", false); defaults.add(isClientAccountNumberLengthModify); HashMap isAccountNumberRandomGenerated = new HashMap<>(); - isAccountNumberRandomGenerated.put("id", 41); isAccountNumberRandomGenerated.put("name", "random-account-number"); - isAccountNumberRandomGenerated.put("value", 0); + isAccountNumberRandomGenerated.put("value", 0L); isAccountNumberRandomGenerated.put("enabled", false); isAccountNumberRandomGenerated.put("trapDoor", false); defaults.add(isAccountNumberRandomGenerated); HashMap isInterestAppropriationEnabled = new HashMap<>(); - isInterestAppropriationEnabled.put("id", 42); isInterestAppropriationEnabled.put("name", "is-interest-to-be-recovered-first-when-greater-than-emi"); - isInterestAppropriationEnabled.put("value", 0); + isInterestAppropriationEnabled.put("value", 0L); isInterestAppropriationEnabled.put("enabled", false); isInterestAppropriationEnabled.put("trapDoor", false); defaults.add(isInterestAppropriationEnabled); HashMap isPrincipalCompoundingDisabled = new HashMap<>(); - isPrincipalCompoundingDisabled.put("id", 43); isPrincipalCompoundingDisabled.put("name", "is-principal-compounding-disabled-for-overdue-loans"); - isPrincipalCompoundingDisabled.put("value", 0); + isPrincipalCompoundingDisabled.put("value", 0L); isPrincipalCompoundingDisabled.put("enabled", false); isPrincipalCompoundingDisabled.put("trapDoor", false); defaults.add(isPrincipalCompoundingDisabled); HashMap isBusinessDateEnabled = new HashMap<>(); - isBusinessDateEnabled.put("id", 44); isBusinessDateEnabled.put("name", "enable_business_date"); - isBusinessDateEnabled.put("value", 0); + isBusinessDateEnabled.put("value", 0L); isBusinessDateEnabled.put("enabled", false); isBusinessDateEnabled.put("trapDoor", false); defaults.add(isBusinessDateEnabled); HashMap isAutomaticCOBDateAdjustmentEnabled = new HashMap<>(); - isAutomaticCOBDateAdjustmentEnabled.put("id", 45); isAutomaticCOBDateAdjustmentEnabled.put("name", "enable_automatic_cob_date_adjustment"); - isAutomaticCOBDateAdjustmentEnabled.put("value", 0); + isAutomaticCOBDateAdjustmentEnabled.put("value", 0L); isAutomaticCOBDateAdjustmentEnabled.put("enabled", true); isAutomaticCOBDateAdjustmentEnabled.put("trapDoor", false); defaults.add(isAutomaticCOBDateAdjustmentEnabled); HashMap isReversalTransactionAllowed = new HashMap<>(); - isReversalTransactionAllowed.put("id", 46); isReversalTransactionAllowed.put("name", "enable-post-reversal-txns-for-reverse-transactions"); - isReversalTransactionAllowed.put("value", 0); + isReversalTransactionAllowed.put("value", 0L); isReversalTransactionAllowed.put("enabled", false); isReversalTransactionAllowed.put("trapDoor", false); defaults.add(isReversalTransactionAllowed); HashMap purgeExternalEventsOlderThanDaysDefault = new HashMap<>(); - purgeExternalEventsOlderThanDaysDefault.put("id", 47); purgeExternalEventsOlderThanDaysDefault.put("name", "purge-external-events-older-than-days"); - purgeExternalEventsOlderThanDaysDefault.put("value", 30); + purgeExternalEventsOlderThanDaysDefault.put("value", 30L); purgeExternalEventsOlderThanDaysDefault.put("enabled", false); purgeExternalEventsOlderThanDaysDefault.put("trapDoor", false); defaults.add(purgeExternalEventsOlderThanDaysDefault); HashMap loanRepaymentDueDaysDefault = new HashMap<>(); - loanRepaymentDueDaysDefault.put("id", 48); loanRepaymentDueDaysDefault.put("name", "days-before-repayment-is-due"); - loanRepaymentDueDaysDefault.put("value", 1); + loanRepaymentDueDaysDefault.put("value", 1L); loanRepaymentDueDaysDefault.put("enabled", false); loanRepaymentDueDaysDefault.put("trapDoor", false); defaults.add(loanRepaymentDueDaysDefault); HashMap loanRepaymentOverdueDaysDefault = new HashMap<>(); - loanRepaymentOverdueDaysDefault.put("id", 49); loanRepaymentOverdueDaysDefault.put("name", "days-after-repayment-is-overdue"); - loanRepaymentOverdueDaysDefault.put("value", 1); + loanRepaymentOverdueDaysDefault.put("value", 1L); loanRepaymentOverdueDaysDefault.put("enabled", false); loanRepaymentOverdueDaysDefault.put("trapDoor", false); defaults.add(loanRepaymentOverdueDaysDefault); HashMap isAutomaticExternalIdGenerationEnabled = new HashMap<>(); - isAutomaticExternalIdGenerationEnabled.put("id", 50); isAutomaticExternalIdGenerationEnabled.put("name", "enable-auto-generated-external-id"); - isAutomaticExternalIdGenerationEnabled.put("value", 0); + isAutomaticExternalIdGenerationEnabled.put("value", 0L); isAutomaticExternalIdGenerationEnabled.put("enabled", false); isAutomaticExternalIdGenerationEnabled.put("trapDoor", false); defaults.add(isAutomaticExternalIdGenerationEnabled); HashMap purgeProcessCommandDaysDefault = new HashMap<>(); - purgeProcessCommandDaysDefault.put("id", 51); purgeProcessCommandDaysDefault.put("name", "purge-processed-commands-older-than-days"); - purgeProcessCommandDaysDefault.put("value", 30); + purgeProcessCommandDaysDefault.put("value", 30L); purgeProcessCommandDaysDefault.put("enabled", false); purgeProcessCommandDaysDefault.put("trapDoor", false); defaults.add(purgeProcessCommandDaysDefault); HashMap isCOBBulkEventEnabled = new HashMap<>(); - isCOBBulkEventEnabled.put("id", 52); isCOBBulkEventEnabled.put("name", "enable-cob-bulk-event"); - isCOBBulkEventEnabled.put("value", 0); + isCOBBulkEventEnabled.put("value", 0L); isCOBBulkEventEnabled.put("enabled", false); isCOBBulkEventEnabled.put("trapDoor", false); defaults.add(isCOBBulkEventEnabled); HashMap externalEventBatchSize = new HashMap<>(); - externalEventBatchSize.put("id", 53); externalEventBatchSize.put("name", "external-event-batch-size"); - externalEventBatchSize.put("value", 1000); + externalEventBatchSize.put("value", 1000L); externalEventBatchSize.put("enabled", false); externalEventBatchSize.put("trapDoor", false); defaults.add(externalEventBatchSize); HashMap reportExportS3FolderName = new HashMap<>(); - reportExportS3FolderName.put("id", 54); reportExportS3FolderName.put("name", "report-export-s3-folder-name"); - reportExportS3FolderName.put("value", 0); + reportExportS3FolderName.put("value", 0L); reportExportS3FolderName.put("enabled", true); reportExportS3FolderName.put("trapDoor", false); defaults.add(reportExportS3FolderName); HashMap loanArrearsDelinquencyDisplayData = new HashMap<>(); - loanArrearsDelinquencyDisplayData.put("id", 55); loanArrearsDelinquencyDisplayData.put("name", "loan-arrears-delinquency-display-data"); - loanArrearsDelinquencyDisplayData.put("value", 0); + loanArrearsDelinquencyDisplayData.put("value", 0L); loanArrearsDelinquencyDisplayData.put("enabled", true); loanArrearsDelinquencyDisplayData.put("trapDoor", false); defaults.add(loanArrearsDelinquencyDisplayData); HashMap accrualForChargeDate = new HashMap<>(); - accrualForChargeDate.put("id", 56); accrualForChargeDate.put("name", "charge-accrual-date"); - accrualForChargeDate.put("value", 0); + accrualForChargeDate.put("value", 0L); accrualForChargeDate.put("enabled", true); accrualForChargeDate.put("trapDoor", false); accrualForChargeDate.put("string_value", "due-date"); defaults.add(accrualForChargeDate); HashMap assetExternalizationOfNonActiveLoans = new HashMap<>(); - assetExternalizationOfNonActiveLoans.put("id", 57); assetExternalizationOfNonActiveLoans.put("name", "asset-externalization-of-non-active-loans"); - assetExternalizationOfNonActiveLoans.put("value", 0); + assetExternalizationOfNonActiveLoans.put("value", 0L); assetExternalizationOfNonActiveLoans.put("enabled", true); assetExternalizationOfNonActiveLoans.put("trapDoor", false); defaults.add(assetExternalizationOfNonActiveLoans); HashMap enableSameMakerChecker = new HashMap<>(); - enableSameMakerChecker.put("id", 58); enableSameMakerChecker.put("name", "enable-same-maker-checker"); - enableSameMakerChecker.put("value", 0); + enableSameMakerChecker.put("value", 0L); enableSameMakerChecker.put("enabled", false); enableSameMakerChecker.put("trapDoor", false); defaults.add(enableSameMakerChecker); HashMap nextPaymentDateConfigForLoan = new HashMap<>(); - nextPaymentDateConfigForLoan.put("id", 59); nextPaymentDateConfigForLoan.put("name", "next-payment-due-date"); - nextPaymentDateConfigForLoan.put("value", 0); + nextPaymentDateConfigForLoan.put("value", 0L); nextPaymentDateConfigForLoan.put("enabled", true); nextPaymentDateConfigForLoan.put("trapDoor", false); nextPaymentDateConfigForLoan.put("string_value", "earliest-unpaid-date"); defaults.add(nextPaymentDateConfigForLoan); HashMap enablePaymentHubIntegrationConfig = new HashMap<>(); - enablePaymentHubIntegrationConfig.put("id", 60); enablePaymentHubIntegrationConfig.put("name", "enable-payment-hub-integration"); - enablePaymentHubIntegrationConfig.put("value", 0); + enablePaymentHubIntegrationConfig.put("value", 0L); enablePaymentHubIntegrationConfig.put("enabled", false); enablePaymentHubIntegrationConfig.put("trapDoor", false); enablePaymentHubIntegrationConfig.put("string_value", "enable payment hub integration"); @@ -602,159 +528,21 @@ private static ArrayList getAllDefaultGlobalConfigurations() { return defaults; } - public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String configId, final String value) { - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; + public PutGlobalConfigurationsResponse updateGlobalConfiguration(final String configName, PutGlobalConfigurationsRequest request) { log.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateValueAsJSON(value), - "resourceId"); + return ok(fineract().globalConfigurations.updateConfigurationByName(configName, request)); } - public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String configId, final int value) { - return updateValueForGlobalConfiguration(requestSpec, responseSpec, configId, Integer.toString(value)); - } - - public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final long configId, final boolean enabled) { - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, - updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId"); - } - - public static void updateValueForGlobalConfigurationInternal(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String configId, final int value) { - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/internal/configurations/" + configId + "/value/" + value + "?" - + Utils.TENANT_IDENTIFIER; + public void updateGlobalConfigurationInternal(final String configName, final Long value) { log.info("---------------------------UPDATE VALUE FOR GLOBAL CONFIG (internal) ---------------------------------------"); - Utils.performServerPost(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, Utils.emptyJson()); - } - - // Deprecated because it's using configId as a String - @Deprecated - public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String configId, final boolean enabled) { - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, - updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId"); - } - - public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { - final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; - log.info("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------"); - final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, GET_IS_CACHE_GLOBAL_CONFIG_URL, ""); - return response; + ok(fineract().legacy.updateGlobalConfiguration(configName, value)); } - public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String cacheType) { - final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; - log.info("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------"); - return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL, - updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes"); - } - - public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, - final String jsonAttributeToGetBack) { - final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); - return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), - jsonAttributeToGetBack); - } - - public static String updateGlobalConfigUpdateValueAsJSON(final String value) { - final HashMap map = new HashMap<>(); - map.put("value", value); - log.info("map : {}", map); - return GSON.toJson(map); - } - - public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) { - final HashMap map = new HashMap<>(); - if (value != null) { - map.put("value", value); - } - map.put("enabled", enabled); - log.info("map : {}", map); - return new Gson().toJson(map); - } - - public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) { - final HashMap map = new HashMap(); - map.put("enabled", enabled); - log.info("map : {}", map); - return new Gson().toJson(map); - } - - public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) { - final HashMap map = new HashMap<>(); - map.put("cacheType", cacheType); - log.info("map : {}", map); - return new Gson().toJson(map); - } - - public static Integer updateIsBusinessDateEnabled(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final boolean enabled) { - long configId = 44; - return updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configId, enabled); - } - - public static void manageConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String configurationName, final boolean enabled) { - GlobalConfigurationPropertyData configuration = getGlobalConfigurationByName(requestSpec, responseSpec, configurationName); + public void manageConfigurations(final String configurationName, final boolean enabled) { + GlobalConfigurationPropertyData configuration = getGlobalConfigurationByName(configurationName); assertNotNull(configuration); - updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configuration.getId(), enabled); - GlobalConfigurationPropertyData updatedConfiguration = getGlobalConfigurationByName(requestSpec, responseSpec, configurationName); + updateGlobalConfiguration(configurationName, new PutGlobalConfigurationsRequest().enabled(enabled)); + GlobalConfigurationPropertyData updatedConfiguration = getGlobalConfigurationByName(configurationName); assertEquals(updatedConfiguration.getEnabled(), enabled); } - - public static Integer updateIsAutomaticExternalIdGenerationEnabled(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final boolean enabled) { - long configId = 50; - return updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, configId, enabled); - } - - public static Integer updateChargeAccrualDateConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String stringValue) { - long configId = 56; - final HashMap map = new HashMap<>(); - map.put("stringValue", stringValue); - log.info("map : {}", map); - final String configValue = GSON.toJson(map); - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, configValue, "resourceId"); - - } - - public static Integer updateLoanNextPaymentDateConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String stringValue) { - long configId = 59; - final HashMap map = new HashMap<>(); - map.put("stringValue", stringValue); - log.info("map : {}", map); - final String configValue = GSON.toJson(map); - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, configValue, "resourceId"); - - } - - public static Integer updateEnablePaymentHubIntegrationConfiguration(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String stringValue) { - long configId = 60; - final HashMap map = new HashMap<>(); - map.put("stringValue", stringValue); - log.info("map : {}", map); - final String configValue = GSON.toJson(map); - final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, configValue, "resourceId"); - - } - } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/datatable/DatatableAdvancedQueryTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/datatable/DatatableAdvancedQueryTest.java index 337c6445252..5b90e3c0b83 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/datatable/DatatableAdvancedQueryTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/datatable/DatatableAdvancedQueryTest.java @@ -61,6 +61,7 @@ import org.apache.fineract.client.models.PagedLocalRequestAdvancedQueryData; import org.apache.fineract.client.models.PagedLocalRequestAdvancedQueryRequest; import org.apache.fineract.client.models.PostDataTablesResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.models.ResultsetColumnHeaderData; import org.apache.fineract.client.models.SortOrder; import org.apache.fineract.client.models.TableQueryData; @@ -106,6 +107,7 @@ public class DatatableAdvancedQueryTest { private DatatableHelper datatableHelper; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -116,6 +118,7 @@ public void setup() { datatableHelper = new DatatableHelper(requestSpec, responseSpec); savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); savingsProductHelper = new SavingsProductHelper(); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -126,7 +129,7 @@ public void testDatatableAdvancedQuery() { LocalDate yesterday = today.minus(1, ChronoUnit.DAYS); String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, yesterdayS); @@ -197,7 +200,8 @@ public void testDatatableAdvancedQuery() { deleteDatatable(datatable, transactionIdD1, transactionIdD2, transactionIdW1); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -210,7 +214,7 @@ public void testApptableWithDatatableAdvancedQuery() { LocalDate yesterday = today.minus(1, ChronoUnit.DAYS); String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); final Integer clientId = ClientHelper.createClient(requestSpec, responseSpec, yesterdayS); @@ -298,7 +302,8 @@ public void testApptableWithDatatableAdvancedQuery() { deleteDatatable(datatable, transactionIdD1, transactionIdD2, transactionIdW1); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/inlinecob/InlineLoanCOBTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/inlinecob/InlineLoanCOBTest.java index 91e820f8ec3..fecb9094b86 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/inlinecob/InlineLoanCOBTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/inlinecob/InlineLoanCOBTest.java @@ -42,19 +42,19 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.PostDelinquencyBucketResponse; import org.apache.fineract.client.models.PostDelinquencyRangeResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; +import org.apache.fineract.integrationtests.BaseLoanIntegrationTest; import org.apache.fineract.integrationtests.common.BatchHelper; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanAccountLockHelper; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyRangesHelper; @@ -63,11 +63,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; @Slf4j -@ExtendWith(LoanTestLifecycleExtension.class) -public class InlineLoanCOBTest { +public class InlineLoanCOBTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -88,10 +86,10 @@ public void setup() { @Test public void testInlineCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -141,14 +139,15 @@ public void testInlineCOB() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBCatchUpLoans() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -236,17 +235,18 @@ public void testInlineCOBCatchUpLoans() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnRepaymentWithSoftLockedLoan() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -295,16 +295,17 @@ public void testInlineCOBOnRepaymentWithSoftLockedLoan() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBCatchUpOnRepaymentWithNotLockedLoan() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -352,16 +353,17 @@ public void testInlineCOBCatchUpOnRepaymentWithNotLockedLoan() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnBatchAPIWithOldRelativeUrls() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -419,16 +421,17 @@ public void testInlineCOBOnBatchAPIWithOldRelativeUrls() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnBatchAPI() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, LocalDate.of(2020, 3, 2)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "0"); + globalConfigurationHelper.updateGlobalConfiguration("penalty-wait-period", new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -486,7 +489,8 @@ public void testInlineCOBOnBatchAPI() { requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); requestSpec.header("Fineract-Platform-TenantId", "default"); responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", + new PutGlobalConfigurationsRequest().enabled(false)); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferCancelTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferCancelTest.java index de22d71bb09..ae233e5d073 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferCancelTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferCancelTest.java @@ -52,12 +52,13 @@ import org.apache.fineract.client.models.PostFinancialActivityAccountsRequest; import org.apache.fineract.client.models.PostInitiateTransferRequest; import org.apache.fineract.client.models.PostInitiateTransferResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.integrationtests.BaseLoanIntegrationTest; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; import org.apache.fineract.integrationtests.common.ExternalAssetOwnerHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -67,17 +68,14 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; @SuppressWarnings("rawtypes") -@ExtendWith(LoanTestLifecycleExtension.class) -public class ExternalAssetOwnerTransferCancelTest { +public class ExternalAssetOwnerTransferCancelTest extends BaseLoanIntegrationTest { public String ownerExternalId; private static ResponseSpecification RESPONSE_SPEC; @@ -133,8 +131,7 @@ private static void setProperFinancialActivity(Account transferAccount) { @Test public void successCancelSale() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -176,8 +173,7 @@ private void getAndValidateThereIsNoJournalEntriesForTransfer(Long transferId) { @Test public void saleAndBuybackOnTheSameDay() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -276,9 +272,8 @@ private void addPenaltyForLoan(Integer loanID, String amount) { } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, LocalDate.parse(date)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "10", "0"); } private void cleanUpAndRestoreBusinessDate() { @@ -287,7 +282,7 @@ private void cleanUpAndRestoreBusinessDate() { REQUEST_SPEC.header("Fineract-Platform-TenantId", "default"); RESPONSE_SPEC = new ResponseSpecBuilder().expectStatusCode(200).build(); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, TODAYS_DATE); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(false)); } @NotNull diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferTest.java index 132f28cb7bf..9a06f288c43 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/ExternalAssetOwnerTransferTest.java @@ -48,12 +48,13 @@ import org.apache.fineract.client.models.PageExternalTransferData; import org.apache.fineract.client.models.PostInitiateTransferRequest; import org.apache.fineract.client.models.PostInitiateTransferResponse; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.integrationtests.BaseLoanIntegrationTest; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; import org.apache.fineract.integrationtests.common.ExternalAssetOwnerHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -69,7 +70,7 @@ import org.junit.jupiter.api.BeforeAll; @Slf4j -public class ExternalAssetOwnerTransferTest { +public class ExternalAssetOwnerTransferTest extends BaseLoanIntegrationTest { protected static ResponseSpecification RESPONSE_SPEC; protected static RequestSpecification REQUEST_SPEC; @@ -156,10 +157,9 @@ protected void addPenaltyForLoan(Integer loanID, String amount) { assertNotNull(penalty1LoanChargeId); } - protected void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); - BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, LocalDate.parse(date)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "10", "0"); + protected void setInitialBusinessDate(LocalDate date) { + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); + BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, date); } protected void cleanUpAndRestoreBusinessDate() { @@ -168,9 +168,8 @@ protected void cleanUpAndRestoreBusinessDate() { REQUEST_SPEC.header("Fineract-Platform-TenantId", "default"); RESPONSE_SPEC = new ResponseSpecBuilder().expectStatusCode(200).build(); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, TODAYS_DATE); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @NotNull diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java index dcab0859895..e34c2dbd3b2 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/InitiateExternalAssetOwnerTransferTest.java @@ -61,14 +61,15 @@ import org.apache.fineract.client.models.PostInitiateTransferRequest; import org.apache.fineract.client.models.PostInitiateTransferResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.infrastructure.event.external.service.validation.ExternalEventDTO; +import org.apache.fineract.integrationtests.BaseLoanIntegrationTest; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; import org.apache.fineract.integrationtests.common.ExternalAssetOwnerHelper; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -80,7 +81,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; -import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.hamcrest.Matchers; import org.jetbrains.annotations.NotNull; @@ -92,8 +92,8 @@ import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") -@ExtendWith({ LoanTestLifecycleExtension.class, ExternalEventsExtension.class }) -public class InitiateExternalAssetOwnerTransferTest { +@ExtendWith({ ExternalEventsExtension.class }) +public class InitiateExternalAssetOwnerTransferTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(InitiateExternalAssetOwnerTransferTest.class); private static ResponseSpecification RESPONSE_SPEC; @@ -150,8 +150,7 @@ private static void setProperFinancialActivity(Account transferAccount) { @Test public void saleActiveLoanToExternalAssetOwnerWithCancelAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); ExternalEventHelper.deleteAllExternalEvents(REQUEST_SPEC, new ResponseSpecBuilder().expectStatusCode(Matchers.is(204)).build()); @@ -350,8 +349,7 @@ public void saleActiveLoanToExternalAssetOwnerWithCancelAndBuybackADayLater() { @Test public void saleActiveLoanToExternalAssetOwnerAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -483,8 +481,7 @@ public void saleActiveLoanToExternalAssetOwnerAndBuybackADayLater() { @Test public void saleOverpaidLoanToExternalAssetOwnerAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -600,8 +597,7 @@ public void saleOverpaidLoanToExternalAssetOwnerAndBuybackADayLater() { @Test public void saleIsNotAllowedWhenTransferIsAlreadyPending() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -619,8 +615,7 @@ public void saleIsNotAllowedWhenTransferIsAlreadyPending() { @Test public void saleIsNotAllowedWhenLoanIsNotActive() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -640,8 +635,7 @@ public void saleIsNotAllowedWhenLoanIsNotActive() { @Test public void saleIsDeclinedWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -664,8 +658,7 @@ public void saleIsDeclinedWhenLoanIsCancelled() { @Test public void buybackIsExecutedWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -696,8 +689,7 @@ public void buybackIsExecutedWhenLoanIsCancelled() { @Test public void buybackAndSaleIsCancelledWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -724,8 +716,7 @@ public void buybackAndSaleIsCancelledWhenLoanIsCancelled() { @Test public void sameDayBuybackAndSaleIsCancelledWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -752,8 +743,7 @@ public void sameDayBuybackAndSaleIsCancelledWhenLoanIsCancelled() { @Test public void saleAndBuybackOnTheSameDay() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -803,8 +793,7 @@ public void saleAndBuybackOnTheSameDay() { @Test public void saleAndBuybackMultipleTimes() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -838,8 +827,7 @@ public void saleAndBuybackMultipleTimes() { @Test public void buybackExceptionHandling() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); CallFailedRuntimeException exception = assertThrows(CallFailedRuntimeException.class, () -> createBuybackTransfer(1, null)); @@ -889,8 +877,7 @@ public void buybackExceptionHandling() { @Test public void saleExceptionHandling() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -979,9 +966,8 @@ private void addPenaltyForLoan(Integer loanID, String amount) { } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, LocalDate.parse(date)); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "10", "0"); } private void cleanUpAndRestoreBusinessDate() { @@ -990,9 +976,8 @@ private void cleanUpAndRestoreBusinessDate() { REQUEST_SPEC.header("Fineract-Platform-TenantId", "default"); RESPONSE_SPEC = new ResponseSpecBuilder().expectStatusCode(200).build(); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, TODAYS_DATE); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.updateGlobalConfiguration("enable_business_date", new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", false); } @NotNull diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/SearchExternalAssetOwnerTransferTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/SearchExternalAssetOwnerTransferTest.java index 13a0c2a4018..07f5da29fed 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/SearchExternalAssetOwnerTransferTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/investor/externalassetowner/SearchExternalAssetOwnerTransferTest.java @@ -31,7 +31,6 @@ import org.apache.fineract.client.models.PageExternalTransferData; import org.apache.fineract.client.models.PagedRequestExternalAssetOwnerSearchRequest; import org.apache.fineract.client.models.PostInitiateTransferResponse; -import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.junit.jupiter.api.Test; @@ -47,9 +46,8 @@ public void saleActiveLoanToExternalAssetOwnerWithSearching() { LocalDate baseLocalDate = Utils.getDateAsLocalDate("29 February 2020"); try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); - setInitialBusinessDate("2020-02-29"); + globalConfigurationHelper.manageConfigurations("enable-auto-generated-external-id", true); + setInitialBusinessDate(LocalDate.of(2020, 2, 29)); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID, "29 February 2020"); addPenaltyForLoan(loanID, "10");