diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationConstants.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationConstants.java new file mode 100644 index 000000000..e2ab1715a --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/api/GlobalConfigurationConstants.java @@ -0,0 +1,80 @@ +/** + * 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.infrastructure.configuration.api; + +public final class GlobalConfigurationConstants { + + public static final String MAKER_CHECKER = "maker-checker"; + public static final String AMAZON_S3 = "amazon-s3"; + public static final String RESCHEDULE_FUTURE_REPAYMENTS = "reschedule-future-repayments"; + public static final String RESCHEDULE_REPAYMENTS_ON_HOLIDAYS = "reschedule-repayments-on-holidays"; + public static final String ALLOW_TRANSACTIONS_ON_HOLIDAY = "allow-transactions-on-holiday"; + public static final String ALLOW_TRANSACTIONS_ON_NON_WORKING_DAY = "allow-transactions-on-non-workingday"; + public static final String CONSTRAINT_APPROACH_FOR_DATATABLES = "constraint-approach-for-datatables"; + public static final String PENALTY_WAIT_PERIOD = "penalty-wait-period"; + public static final String FORCE_PASSWORD_RESET_DAYS = "force-password-reset-days"; + public static final String GRACE_ON_PENALTY_POSTING = "grace-on-penalty-posting"; + public static final String SAVINGS_INTEREST_POSTING_CURRENT_PERIOD_END = "savings-interest-posting-current-period-end"; + public static final String FINANCIAL_YEAR_BEGINNING_MONTH = "financial-year-beginning-month"; + public static final String MIN_CLIENTS_IN_GROUP = "min-clients-in-group"; + public static final String MAX_CLIENTS_IN_GROUP = "max-clients-in-group"; + public static final String MEETINGS_MANDATORY_FOR_JLG_LOANS = "meetings-mandatory-for-jlg-loans"; + public static final String OFFICE_SPECIFIC_PRODUCTS_ENABLED = "office-specific-products-enabled"; + public static final String RESTRICT_PRODUCTS_TO_USER_OFFICE = "restrict-products-to-user-office"; + public static final String OFFICE_OPENING_BALANCES_CONTRA_ACCOUNT = "office-opening-balances-contra-account"; + public static final String ROUNDING_MODE = "rounding-mode"; + public static final String BACKDATE_PENALTIES_ENABLED = "backdate-penalties-enabled"; + public static final String ORGANISATION_START_DATE = "organisation-start-date"; + public static final String PAYMENT_TYPE_APPLICABLE_FOR_DISBURSEMENT_CHARGES = "paymenttype-applicable-for-disbursement-charges"; + public static final String INTEREST_CHARGED_FROM_DATE_SAME_AS_DISBURSAL_DATE = "interest-charged-from-date-same-as-disbursal-date"; + public static final String SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH = "skip-repayment-on-first-day-of-month"; + public static final String CHANGE_EMI_IF_REPAYMENT_DATE_SAME_AS_DISBURSEMENT_DATE = "change-emi-if-repaymentdate-same-as-disbursementdate"; + public static final String DAILY_TPT_LIMIT = "daily-tpt-limit"; + public static final String ENABLE_ADDRESS = "enable-address"; + public static final String SUB_RATES = "sub-rates"; + public static final String LOAN_RESCHEDULE_IS_FIRST_PAYDAY_ALLOWED_ON_HOLIDAY = "loan-reschedule-is-first-payday-allowed-on-holiday"; + public static final String ACCOUNT_MAPPING_FOR_PAYMENT_TYPE = "account-mapping-for-payment-type"; + public static final String ACCOUNT_MAPPING_FOR_CHARGE = "account-mapping-for-charge"; + public static final String FIXED_DEPOSIT_TRANSFER_INTEREST_NEXT_DAY_FOR_PERIOD_END_POSTING = "fixed-deposit-transfer-interest-next-day-for-period-end-posting"; + public static final String ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING = "allow-backdated-transaction-before-interest-posting"; + public static final String ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING_DATE_FOR_DAYS = "allow-backdated-transaction-before-interest-posting-date-for-days"; + public static final String CUSTOM_ACCOUNT_NUMBER_LENGTH = "custom-account-number-length"; + public static final String RANDOM_ACCOUNT_NUMBER = "random-account-number"; + public static final String IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI = "is-interest-to-be-recovered-first-when-greater-than-emi"; + public static final String IS_PRINCIPAL_COMPOUNDING_DISABLED_FOR_OVERDUE_LOANS = "is-principal-compounding-disabled-for-overdue-loans"; + public static final String ENABLE_BUSINESS_DATE = "enable-business-date"; + public static final String ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT = "enable-automatic-cob-date-adjustment"; + public static final String ENABLE_POST_REVERSAL_TXNS_FOR_REVERSE_TRANSACTIONS = "enable-post-reversal-txns-for-reverse-transactions"; + public static final String PURGE_EXTERNAL_EVENTS_OLDER_THAN_DAYS = "purge-external-events-older-than-days"; + public static final String DAYS_BEFORE_REPAYMENT_IS_DUE = "days-before-repayment-is-due"; + public static final String DAYS_AFTER_REPAYMENT_IS_OVERDUE = "days-after-repayment-is-overdue"; + public static final String ENABLE_AUTO_GENERATED_EXTERNAL_ID = "enable-auto-generated-external-id"; + public static final String PURGE_PROCESSED_COMMANDS_OLDER_THAN_DAYS = "purge-processed-commands-older-than-days"; + public static final String ENABLE_COB_BULK_EVENT = "enable-cob-bulk-event"; + public static final String EXTERNAL_EVENT_BATCH_SIZE = "external-event-batch-size"; + public static final String REPORT_EXPORT_S3_FOLDER_NAME = "report-export-s3-folder-name"; + public static final String LOAN_ARREARS_DELINQUENCY_DISPLAY_DATA = "loan-arrears-delinquency-display-data"; + public static final String CHARGE_ACCRUAL_DATE = "charge-accrual-date"; + public static final String ASSET_EXTERNALIZATION_OF_NON_ACTIVE_LOANS = "asset-externalization-of-non-active-loans"; + public static final String ENABLE_SAME_MAKER_CHECKER = "enable-same-maker-checker"; + public static final String NEXT_PAYMENT_DUE_DATE = "next-payment-due-date"; + public static final String ENABLE_PAYMENT_HUB_INTEGRATION = "enable-payment-hub-integration"; + + private GlobalConfigurationConstants() {} +} diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/exception/GlobalConfigurationException.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/exception/GlobalConfigurationException.java new file mode 100644 index 000000000..7b20feaf8 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/exception/GlobalConfigurationException.java @@ -0,0 +1,27 @@ +/** + * 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.infrastructure.configuration.exception; + +public class GlobalConfigurationException extends RuntimeException { + + public GlobalConfigurationException(final String name) { + super("Global configuration with name: '" + name + + "' is not in the supported format! Global configuration name can only contains lowercase letters or -, and must start with letters!"); + } +} diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/service/GlobalConfigurationValidationService.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/service/GlobalConfigurationValidationService.java new file mode 100644 index 000000000..b11ea5772 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/configuration/service/GlobalConfigurationValidationService.java @@ -0,0 +1,73 @@ +/** + * 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.infrastructure.configuration.service; + +import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationException; +import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant; +import org.apache.fineract.infrastructure.core.service.JdbcTemplateFactory; +import org.apache.fineract.infrastructure.core.service.tenant.TenantDetailsService; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Slf4j +@RequiredArgsConstructor +@Service +public class GlobalConfigurationValidationService implements InitializingBean { + + private static final String GLOBAL_CONFIGURATION_NAME_PATTERN = "^[a-z][a-z0-9-]*$"; + private final TenantDetailsService tenantDetailsService; + private final JdbcTemplateFactory jdbcTemplateFactory; + + @Override + public void afterPropertiesSet() throws Exception { + validateGlobalConfigurationNames(); + } + + private void validateGlobalConfigurationNames() { + List tenants = tenantDetailsService.findAllTenants(); + + if (isNotEmpty(tenants)) { + for (FineractPlatformTenant tenant : tenants) { + validateGlobalConfigurationForIndividualTenant(tenant); + } + } + } + + private void validateGlobalConfigurationForIndividualTenant(FineractPlatformTenant tenant) { + log.debug("Validating global configuration for {}", tenant.getTenantIdentifier()); + List globalConfigurationNames = getGlobalConfigurationNames(tenant); + + globalConfigurationNames.forEach(globalConfigurationName -> { + if (!globalConfigurationName.matches(GLOBAL_CONFIGURATION_NAME_PATTERN)) { + throw new GlobalConfigurationException(globalConfigurationName); + } + }); + } + + private List getGlobalConfigurationNames(FineractPlatformTenant tenant) { + final JdbcTemplate jdbcTemplate = jdbcTemplateFactory.create(tenant); + return jdbcTemplate.queryForList("select gc.name as name from c_configuration gc", String.class); + } +} diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/JdbcTemplateFactory.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/JdbcTemplateFactory.java similarity index 96% rename from fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/JdbcTemplateFactory.java rename to fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/JdbcTemplateFactory.java index af162baa7..b3c3cda91 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/JdbcTemplateFactory.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/JdbcTemplateFactory.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.infrastructure.event.external.service; +package org.apache.fineract.infrastructure.core.service; import javax.sql.DataSource; import lombok.RequiredArgsConstructor; diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationService.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationService.java index 30af0a0f8..e363fed1e 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationService.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationService.java @@ -29,6 +29,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant; +import org.apache.fineract.infrastructure.core.service.JdbcTemplateFactory; import org.apache.fineract.infrastructure.core.service.tenant.TenantDetailsService; import org.apache.fineract.infrastructure.event.business.domain.BulkBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent; diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GlobalConfigurationGlobalInitializerStep.java b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GlobalConfigurationGlobalInitializerStep.java index 9d3e0cf47..bb804c510 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GlobalConfigurationGlobalInitializerStep.java +++ b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/GlobalConfigurationGlobalInitializerStep.java @@ -29,10 +29,10 @@ import org.springframework.stereotype.Component; @Order(Ordered.HIGHEST_PRECEDENCE) public class GlobalConfigurationGlobalInitializerStep implements FineractGlobalInitializerStep { - public static final String CONFIG_KEY_ENABLE_ADDRESS = "Enable-Address"; + public static final String CONFIG_KEY_ENABLE_ADDRESS = "enable-address"; public static final String CONFIG_KEY_ENABLE_INTEREST_CALCULATION = "interest-charged-from-date-same-as-disbursal-date"; - public static final String CONFIG_KEY_ENABLE_BUSINESS_DATE = "enable_business_date"; - public static final String CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE = "enable_automatic_cob_date_adjustment"; + public static final String CONFIG_KEY_ENABLE_BUSINESS_DATE = "enable-business-date"; + public static final String CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE = "enable-automatic-cob-date-adjustment"; public static final String CONFIG_KEY_DAYS_BEFORE_REPAYMENT_IS_DUE = "days-before-repayment-is-due"; public static final String CONFIG_KEY_DAYS_AFTER_REPAYMENT_IS_OVERDUE = "days-after-repayment-is-overdue"; public static final String CONFIG_KEY_ENABLE_AUTO_GENERATED_EXTERNAL_ID = "enable-auto-generated-external-id"; diff --git a/fineract-e2e-tests-runner/src/test/resources/features/BusinessDate.feature b/fineract-e2e-tests-runner/src/test/resources/features/BusinessDate.feature index 2abd5d1ac..1001ecf71 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/BusinessDate.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/BusinessDate.feature @@ -3,11 +3,11 @@ Feature: BusinessDate Scenario: As a user I would like to enable the Business date configuration - Given Global configuration "enable_business_date" is enabled + Given Global configuration "enable-business-date" is enabled Scenario: As a user I would like to disable the Business date configuration - Given Global configuration "enable_business_date" is disabled + Given Global configuration "enable-business-date" is disabled Scenario: As a user I would like to set the business date diff --git a/fineract-e2e-tests-runner/src/test/resources/features/Client.feature b/fineract-e2e-tests-runner/src/test/resources/features/Client.feature index 2a053b42e..3ea0d5ac0 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/Client.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/Client.feature @@ -30,7 +30,7 @@ Feature: Client Scenario Outline: Client creation with address functionality for Fineract - When Global configuration "Enable-Address" is enabled + When Global configuration "enable-address" is enabled When Admin creates a client with Firstname and Lastname with address Then Client is created successfully Examples: diff --git a/fineract-e2e-tests-runner/src/test/resources/features/Loan.feature b/fineract-e2e-tests-runner/src/test/resources/features/Loan.feature index ccd8c5f16..3af5410f0 100644 --- a/fineract-e2e-tests-runner/src/test/resources/features/Loan.feature +++ b/fineract-e2e-tests-runner/src/test/resources/features/Loan.feature @@ -5659,7 +5659,7 @@ Feature: Loan When Admin set "LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_TILL_REST_FREQUENCY" loan product "DEFAULT" transaction type to "LAST_INSTALLMENT" future installment allocation rule Scenario: Interest recalculation - S1 daily for overdue loan - Given Global configuration "enable_business_date" is enabled + Given Global configuration "enable-business-date" is enabled When Admin sets the business date to "1 January 2024" When Admin creates a client with random data When Admin creates a fully customized loan with the following data: @@ -5682,7 +5682,7 @@ Feature: Loan When Admin removes "LOAN_INTEREST_RECALCULATION" business step into LOAN_CLOSE_OF_BUSINESS workflow Scenario: Interest recalculation - S2 2 overdue - Given Global configuration "enable_business_date" is enabled + Given Global configuration "enable-business-date" is enabled When Admin sets the business date to "1 January 2024" When Admin creates a client with random data When Admin creates a fully customized loan with the following data: @@ -5705,7 +5705,7 @@ Feature: Loan When Admin removes "LOAN_INTEREST_RECALCULATION" business step into LOAN_CLOSE_OF_BUSINESS workflow Scenario: Interest recalculation - S3 1 paid, 1 overdue - Given Global configuration "enable_business_date" is enabled + Given Global configuration "enable-business-date" is enabled When Admin sets the business date to "1 January 2024" When Admin creates a client with random data When Admin creates a fully customized loan with the following data: 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 a218a2bbc..b8e3b13e4 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 @@ -59,7 +59,7 @@ import org.springframework.stereotype.Component; @Tag(name = "Global Configuration", description = "Global configuration related to set of supported enable/disable configurations:\n" + "\n" + "maker-checker - defaults to false - if true turns on maker-checker functionality\n" + "reschedule-future-repayments - defaults to false - if true reschedules repayemnts which falls on a non-working day to configured repayment rescheduling rule\n" - + "allow-transactions-on-non_workingday - defaults to false - if true allows transactions on non-working days\n" + + "allow-transactions-on-non-workingday - defaults to false - if true allows transactions on non-working days\n" + "reschedule-repayments-on-holidays - defaults to false - if true reschedules repayemnts which falls on a non-working day to defined reschedule date\n" + "allow-transactions-on-holiday - defaults to false - if true allows transactions on holidays\n" + "savings-interest-posting-current-period-end - Set it at the database level before any savings interest is posted. When set as false(default), interest will be posted on the first date of next period. If set as true, interest will be posted on last date of current period. There is no difference in the interest amount posted.\n" @@ -123,7 +123,7 @@ public class GlobalConfigurationApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Retrieve Global Configuration", description = "Returns a global enable/disable configuration.\n" + "\n" - + "Example Requests:\n" + "\n" + "configurations/name/Enable-Address") + + "Example Requests:\n" + "\n" + "configurations/name/enable-address") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GlobalConfigurationPropertyData.class))) }) public String retrieveOneByName(@PathParam("name") @Parameter(description = "name") final String name, @Context final UriInfo uriInfo) { @@ -156,4 +156,29 @@ public class GlobalConfigurationApiResource { 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 515ebbf77..127b4c391 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 @@ package org.apache.fineract.infrastructure.configuration.api; 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.apache.fineract.organisation.monetary.domain.MoneyHelper; 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 class InternalConfigurationsApiResource implements InitializingBean { } - @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/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java index 7c2bf1740..386fc6635 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.fineract.infrastructure.cache.domain.CacheType; import org.apache.fineract.infrastructure.cache.domain.PlatformCache; import org.apache.fineract.infrastructure.cache.domain.PlatformCacheRepository; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.data.GlobalConfigurationPropertyData; import org.apache.fineract.useradministration.domain.Permission; import org.apache.fineract.useradministration.domain.PermissionRepository; @@ -38,23 +39,6 @@ import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor public class ConfigurationDomainServiceJpa implements ConfigurationDomainService { - public static final String ENABLE_BUSINESS_DATE = "enable_business_date"; - public static final String ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT = "enable_automatic_cob_date_adjustment"; - public static final String EXTERNAL_EVENTS_PURGE_DAYS = "purge-external-events-older-than-days"; - - public static final String PROCESSED_COMMANDS_PURGE_DAYS = "purge-processed-commands-older-than-days"; - private static final String DAYS_BEFORE_REPAYMENT_IS_DUE = "days-before-repayment-is-due"; - private static final String DAYS_AFTER_REPAYMENT_IS_OVERDUE = "days-after-repayment-is-overdue"; - private static final String ENABLE_EXTERNAL_ID_AUTO_GENERATION = "enable-auto-generated-external-id"; - private static final String ENABLE_ADDRESS = "Enable-Address"; - private static final String ENABLE_COB_BULK_EVENT = "enable-cob-bulk-event"; - private static final String EXTERNAL_EVENT_BATCH_SIZE = "external-event-batch-size"; - - private static final String REPORT_EXPORT_S3_FOLDER_NAME = "report-export-s3-folder-name"; - - public static final String CHARGE_ACCRUAL_DATE_CRITERIA = "charge-accrual-date"; - public static final String NEXT_PAYMENT_DUE_DATE = "next-payment-due-date"; - private final PermissionRepository permissionRepository; private final GlobalConfigurationRepositoryWrapper globalConfigurationRepository; private final PlatformCacheRepository cacheTypeRepository; @@ -64,8 +48,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService if (StringUtils.isBlank(taskPermissionCode)) { throw new PermissionNotFoundException(taskPermissionCode); } - final String makerCheckerConfigurationProperty = "maker-checker"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(makerCheckerConfigurationProperty); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(GlobalConfigurationConstants.MAKER_CHECKER); if (property.isEnabled()) { final Permission thisTask = this.permissionRepository.findOneByCode(taskPermissionCode); if (thisTask == null) { @@ -79,18 +62,18 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean isSameMakerCheckerEnabled() { - return getGlobalConfigurationPropertyData("enable-same-maker-checker").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.ENABLE_SAME_MAKER_CHECKER).isEnabled(); } @Override public boolean isAmazonS3Enabled() { - return getGlobalConfigurationPropertyData("amazon-S3").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.AMAZON_S3).isEnabled(); } @Override public boolean isRescheduleFutureRepaymentsEnabled() { - final String rescheduleRepaymentsConfigurationProperty = "reschedule-future-repayments"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(rescheduleRepaymentsConfigurationProperty); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.RESCHEDULE_FUTURE_REPAYMENTS); return property.isEnabled(); } @@ -101,29 +84,29 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService */ @Override public boolean isRescheduleRepaymentsOnHolidaysEnabled() { - final String holidaysConfigurationProperty = "reschedule-repayments-on-holidays"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(holidaysConfigurationProperty); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.RESCHEDULE_REPAYMENTS_ON_HOLIDAYS); return property.isEnabled(); } @Override public boolean allowTransactionsOnHolidayEnabled() { - final String allowTransactionsOnHolidayProperty = "allow-transactions-on-holiday"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(allowTransactionsOnHolidayProperty); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_HOLIDAY); return property.isEnabled(); } @Override public boolean allowTransactionsOnNonWorkingDayEnabled() { - final String propertyName = "allow-transactions-on-non_workingday"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_NON_WORKING_DAY); return property.isEnabled(); } @Override public boolean isConstraintApproachEnabledForDatatables() { - final String propertyName = "constraint_approach_for_datatables"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.CONSTRAINT_APPROACH_FOR_DATATABLES); return property.isEnabled(); } @@ -143,50 +126,50 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public Long retrievePenaltyWaitPeriod() { - final String propertyName = "penalty-wait-period"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.PENALTY_WAIT_PERIOD); return property.getValue(); } @Override public Long retrieveGraceOnPenaltyPostingPeriod() { - final String propertyName = "grace-on-penalty-posting"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.GRACE_ON_PENALTY_POSTING); return property.getValue(); } @Override public boolean isPasswordForcedResetEnable() { - final String propertyName = "force-password-reset-days"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS); return property.isEnabled(); } @Override public Long retrievePasswordLiveTime() { - final String propertyName = "force-password-reset-days"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS); return property.getValue(); } @Override public Long retrieveOpeningBalancesContraAccount() { - final String propertyName = "office-opening-balances-contra-account"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.OFFICE_OPENING_BALANCES_CONTRA_ACCOUNT); return property.getValue(); } @Override public boolean isSavingsInterestPostingAtCurrentPeriodEnd() { - final String propertyName = "savings-interest-posting-current-period-end"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.SAVINGS_INTEREST_POSTING_CURRENT_PERIOD_END); return property.isEnabled(); } @Override public Integer retrieveFinancialYearBeginningMonth() { - final String propertyName = "financial-year-beginning-month"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.FINANCIAL_YEAR_BEGINNING_MONTH); if (property.isEnabled()) { return property.getValue().intValue(); } @@ -195,8 +178,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public Integer retrieveMinAllowedClientsInGroup() { - final String propertyName = "min-clients-in-group"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.MIN_CLIENTS_IN_GROUP); if (property.isEnabled()) { return property.getValue().intValue(); } @@ -205,8 +188,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public Integer retrieveMaxAllowedClientsInGroup() { - final String propertyName = "max-clients-in-group"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.MAX_CLIENTS_IN_GROUP); if (property.isEnabled()) { return property.getValue().intValue(); } @@ -215,16 +198,15 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean isMeetingMandatoryForJLGLoans() { - final String propertyName = "meetings-mandatory-for-jlg-loans"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.MEETINGS_MANDATORY_FOR_JLG_LOANS); return property.isEnabled(); } @Override public int getRoundingMode() { - final String propertyName = "rounding-mode"; int defaultValue = 6; // 6 Stands for HALF-EVEN - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(GlobalConfigurationConstants.ROUNDING_MODE); if (property.isEnabled()) { int value = property.getValue().intValue(); if (value < 0 || value > 6) { @@ -237,78 +219,80 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean isBackdatePenaltiesEnabled() { - final String propertyName = "backdate-penalties-enabled"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.BACKDATE_PENALTIES_ENABLED); return property.isEnabled(); } @Override public boolean isOrganisationstartDateEnabled() { - final String propertyName = "organisation-start-date"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ORGANISATION_START_DATE); return property.isEnabled(); } @Override public LocalDate retrieveOrganisationStartDate() { - final String propertyName = "organisation-start-date"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ORGANISATION_START_DATE); return property.getDateValue(); } @Override public boolean isPaymentTypeApplicableForDisbursementCharge() { - final String propertyName = "paymenttype-applicable-for-disbursement-charges"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.PAYMENT_TYPE_APPLICABLE_FOR_DISBURSEMENT_CHARGES); return property.isEnabled(); } @Override public boolean isSkippingMeetingOnFirstDayOfMonthEnabled() { - return getGlobalConfigurationPropertyData("skip-repayment-on-first-day-of-month").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH).isEnabled(); } @Override public boolean isFirstRepaymentDateAfterRescheduleAllowedOnHoliday() { - return getGlobalConfigurationPropertyData("loan-reschedule-is-first-payday-allowed-on-holiday").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.LOAN_RESCHEDULE_IS_FIRST_PAYDAY_ALLOWED_ON_HOLIDAY) + .isEnabled(); } @Override public boolean isInterestToBeRecoveredFirstWhenGreaterThanEMI() { - return getGlobalConfigurationPropertyData("is-interest-to-be-recovered-first-when-greater-than-emi").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI) + .isEnabled(); } @Override public boolean isPrincipalCompoundingDisabledForOverdueLoans() { - return getGlobalConfigurationPropertyData("is-principal-compounding-disabled-for-overdue-loans").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.IS_PRINCIPAL_COMPOUNDING_DISABLED_FOR_OVERDUE_LOANS) + .isEnabled(); } @Override public Long retreivePeriodInNumberOfDaysForSkipMeetingDate() { - final String propertyName = "skip-repayment-on-first-day-of-month"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH); return property.getValue(); } @Override public boolean isInterestChargedFromDateSameAsDisbursementDate() { - final String propertyName = "interest-charged-from-date-same-as-disbursal-date"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.INTEREST_CHARGED_FROM_DATE_SAME_AS_DISBURSAL_DATE); return property.isEnabled(); } @Override public boolean isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled() { - final String propertyName = "change-emi-if-repaymentdate-same-as-disbursementdate"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.CHANGE_EMI_IF_REPAYMENT_DATE_SAME_AS_DISBURSEMENT_DATE); return property.isEnabled(); } @Override public boolean isDailyTPTLimitEnabled() { - final String propertyName = "daily-tpt-limit"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(GlobalConfigurationConstants.DAILY_TPT_LIMIT); return property.isEnabled(); } @@ -364,23 +348,23 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean retrievePivotDateConfig() { - final String propertyName = "allow-backdated-transaction-before-interest-posting"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING); return !property.isEnabled(); } @Override public boolean isRelaxingDaysConfigForPivotDateEnabled() { - final String propertyName = "allow-backdated-transaction-before-interest-posting-date-for-days"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING_DATE_FOR_DAYS); return property.isEnabled(); } @Override public Long retrieveRelaxingDaysConfigForPivotDate() { - final String propertyName = "allow-backdated-transaction-before-interest-posting-date-for-days"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING_DATE_FOR_DAYS); if (property.getValue() == null) { return 0L; } @@ -394,14 +378,14 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean isSubRatesEnabled() { - return getGlobalConfigurationPropertyData("sub-rates").isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.SUB_RATES).isEnabled(); } @Override public String getAccountMappingForPaymentType() { - final String propertyName = "account-mapping-for-payment-type"; String defaultValue = "Asset"; // 1 Stands for Account mapped from asset only - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_PAYMENT_TYPE); if (property.isEnabled()) { String value = property.getStringValue(); if (StringUtils.isBlank(value)) { @@ -414,9 +398,9 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public String getAccountMappingForCharge() { - final String propertyName = "account-mapping-for-charge"; String defaultValue = "Income"; // 1 Stands for Account mapped from income only - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_CHARGE); if (property.isEnabled()) { String value = property.getStringValue(); if (StringUtils.isBlank(value)) { @@ -429,88 +413,97 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public boolean isNextDayFixedDepositInterestTransferEnabledForPeriodEnd() { - final String propertyName = "fixed-deposit-transfer-interest-next-day-for-period-end-posting"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.FIXED_DEPOSIT_TRANSFER_INTEREST_NEXT_DAY_FOR_PERIOD_END_POSTING); return property.isEnabled(); } @Override public boolean isBusinessDateEnabled() { - return getGlobalConfigurationPropertyData(ENABLE_BUSINESS_DATE).isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE).isEnabled(); } @Override public boolean isCOBDateAdjustmentEnabled() { - return getGlobalConfigurationPropertyData(ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT).isEnabled(); + return getGlobalConfigurationPropertyData(GlobalConfigurationConstants.ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT).isEnabled(); } @Override public boolean isReversalTransactionAllowed() { - final String propertyName = "enable-post-reversal-txns-for-reverse-transactions"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ENABLE_POST_REVERSAL_TXNS_FOR_REVERSE_TRANSACTIONS); return property.isEnabled(); } @Override public Long retrieveExternalEventsPurgeDaysCriteria() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(EXTERNAL_EVENTS_PURGE_DAYS); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.PURGE_EXTERNAL_EVENTS_OLDER_THAN_DAYS); return property.getValue(); } @Override public Long retrieveProcessedCommandsPurgeDaysCriteria() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(PROCESSED_COMMANDS_PURGE_DAYS); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.PURGE_PROCESSED_COMMANDS_OLDER_THAN_DAYS); return property.getValue(); } @Override public Long retrieveRepaymentDueDays() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(DAYS_BEFORE_REPAYMENT_IS_DUE); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.DAYS_BEFORE_REPAYMENT_IS_DUE); return property.getValue(); } @Override public Long retrieveRepaymentOverdueDays() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(DAYS_AFTER_REPAYMENT_IS_OVERDUE); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.DAYS_AFTER_REPAYMENT_IS_OVERDUE); return property.getValue(); } @Override public boolean isExternalIdAutoGenerationEnabled() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(ENABLE_EXTERNAL_ID_AUTO_GENERATION); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID); return property.isEnabled(); } @Override public boolean isAddressEnabled() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(ENABLE_ADDRESS); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(GlobalConfigurationConstants.ENABLE_ADDRESS); return property.isEnabled(); } @Override public boolean isCOBBulkEventEnabled() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(ENABLE_COB_BULK_EVENT); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.ENABLE_COB_BULK_EVENT); return property.isEnabled(); } @Override public Long retrieveExternalEventBatchSize() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(EXTERNAL_EVENT_BATCH_SIZE); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.EXTERNAL_EVENT_BATCH_SIZE); return property.getValue(); } @Override public String retrieveReportExportS3FolderName() { - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(REPORT_EXPORT_S3_FOLDER_NAME); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.REPORT_EXPORT_S3_FOLDER_NAME); return property.getStringValue(); } @Override public String getAccrualDateConfigForCharge() { String defaultValue = "due-date"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(CHARGE_ACCRUAL_DATE_CRITERIA); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE); String value = property.getStringValue(); if (StringUtils.isBlank(value)) { return defaultValue; @@ -521,7 +514,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService @Override public String getNextPaymentDateConfigForLoan() { String defaultValue = "earliest-unpaid-date"; - final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(NEXT_PAYMENT_DUE_DATE); + final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData( + GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE); String value = property.getStringValue(); if (StringUtils.isBlank(value)) { return defaultValue; diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java index 89b3707e9..d6689a2fc 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java @@ -28,6 +28,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.data.GlobalConfigurationPropertyData; import org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied; import org.apache.fineract.infrastructure.core.api.JsonCommand; @@ -99,7 +100,7 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom this.stringValue = newStringValue; } - final String passwordPropertyName = "force-password-reset-days"; + final String passwordPropertyName = GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS; if (this.name.equalsIgnoreCase(passwordPropertyName)) { if ((this.enabled == true && command.hasParameter(valueParamName) && (this.value == 0)) || (this.enabled == true && !command.hasParameter(valueParamName) && (previousValue == 0))) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/FineractEntityAccessConstants.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/FineractEntityAccessConstants.java index 6ceccea03..237db0c28 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/FineractEntityAccessConstants.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/FineractEntityAccessConstants.java @@ -24,8 +24,6 @@ public final class FineractEntityAccessConstants { } - public static final String GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS = "office-specific-products-enabled"; - public static final String GLOBAL_CONFIG_FOR_RESTRICT_PRODUCTS_TO_USER_OFFICE = "restrict-products-to-user-office"; public static final String ENTITY_ACCESS_CODENAME = "Entity to Entity Access Types"; /*** diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java index 060320fd7..6a07f62d9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java @@ -21,9 +21,9 @@ package org.apache.fineract.infrastructure.entityaccess.service; import java.time.LocalDate; import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationProperty; import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationRepositoryWrapper; -import org.apache.fineract.infrastructure.entityaccess.FineractEntityAccessConstants; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityRelation; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityRelationRepositoryWrapper; @@ -77,13 +77,13 @@ public class FineractEntityAccessUtil { // i.e. this product or charge is specific for this office. final GlobalConfigurationProperty property = this.globalConfigurationRepository - .findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS); + .findOneByNameWithNotFoundDetection(GlobalConfigurationConstants.OFFICE_SPECIFIC_PRODUCTS_ENABLED); if (property.isEnabled()) { // If this property is enabled, then Fineract need to restrict // access to this loan product to only the office of the current // user final GlobalConfigurationProperty restrictToUserOfficeProperty = this.globalConfigurationRepository - .findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_RESTRICT_PRODUCTS_TO_USER_OFFICE); + .findOneByNameWithNotFoundDetection(GlobalConfigurationConstants.RESTRICT_PRODUCTS_TO_USER_OFFICE); if (restrictToUserOfficeProperty.isEnabled()) { final Long officeId = thisUser.getOffice().getId(); @@ -105,7 +105,7 @@ public class FineractEntityAccessUtil { String inClause = ""; final GlobalConfigurationProperty property = this.globalConfigurationRepository - .findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS); + .findOneByNameWithNotFoundDetection(GlobalConfigurationConstants.OFFICE_SPECIFIC_PRODUCTS_ENABLED); if (property.isEnabled()) { // Get 'SQL In Clause' for fetching only products/charges that are diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/service/StuckJobListener.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/service/StuckJobListener.java index 6898e1be6..16998a3c8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/service/StuckJobListener.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/service/StuckJobListener.java @@ -26,9 +26,9 @@ import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.businessdate.service.BusinessDateReadPlatformService; import org.apache.fineract.infrastructure.core.domain.ActionContext; import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant; +import org.apache.fineract.infrastructure.core.service.JdbcTemplateFactory; import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil; import org.apache.fineract.infrastructure.core.service.tenant.TenantDetailsService; -import org.apache.fineract.infrastructure.event.external.service.JdbcTemplateFactory; import org.apache.fineract.infrastructure.jobs.domain.JobExecutionRepository; import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUserRepositoryWrapper; diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/workingdays/api/WorkingDaysApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/workingdays/api/WorkingDaysApiResource.java index f9ddd4077..d1c1be6a3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/organisation/workingdays/api/WorkingDaysApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/workingdays/api/WorkingDaysApiResource.java @@ -53,7 +53,7 @@ import org.springframework.stereotype.Component; @Tag(name = "Working days", description = "The days of the week that are workdays.\n" + "\n" + "Rescheduling of repayments when it falls on a non-working is turned on /off by enable/disable reschedule-future-repayments parameter in Global configurations\n" + "\n" - + "Allow transactions on non-working days is configurable by enabling/disbaling the allow-transactions-on-non_workingday parameter in Global configurations.") + + "Allow transactions on non-working days is configurable by enabling/disbaling the allow-transactions-on-non-workingday parameter in Global configurations.") @RequiredArgsConstructor public class WorkingDaysApiResource { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountNumberGenerator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountNumberGenerator.java index ea578eb2a..7d92e50a4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountNumberGenerator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountNumberGenerator.java @@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormat; import org.apache.fineract.infrastructure.accountnumberformat.domain.AccountNumberFormatEnumerations.AccountNumberPrefixType; import org.apache.fineract.infrastructure.codes.domain.CodeValue; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.data.GlobalConfigurationPropertyData; import org.apache.fineract.infrastructure.configuration.service.ConfigurationReadPlatformService; import org.apache.fineract.portfolio.client.domain.Client; @@ -105,7 +106,7 @@ public class AccountNumberGenerator { // find if the custom length is defined final GlobalConfigurationPropertyData customLength = this.configurationReadPlatformService - .retrieveGlobalConfiguration("custom-account-number-length"); + .retrieveGlobalConfiguration(GlobalConfigurationConstants.CUSTOM_ACCOUNT_NUMBER_LENGTH); if (customLength.isEnabled()) { // if it is enabled, and has the value, get it from the repository. @@ -115,7 +116,7 @@ public class AccountNumberGenerator { } final GlobalConfigurationPropertyData randomAccountNumber = this.configurationReadPlatformService - .retrieveGlobalConfiguration("random-account-number"); + .retrieveGlobalConfiguration(GlobalConfigurationConstants.RANDOM_ACCOUNT_NUMBER); if (randomAccountNumber.isEnabled()) { accountNumber = randomNumberGenerator(accountMaxLength, propertyMap); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientDataValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientDataValidator.java index f8a5b9274..9460eff7a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientDataValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientDataValidator.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.service.ConfigurationReadPlatformService; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.data.ApiParameterError; @@ -224,7 +225,7 @@ public final class ClientDataValidator { baseDataValidator.reset().parameter("isStaff").value(isStaffFlag).notNull(); } - if (this.configurationReadPlatformService.retrieveGlobalConfiguration("Enable-Address").isEnabled()) { + if (this.configurationReadPlatformService.retrieveGlobalConfiguration(GlobalConfigurationConstants.ENABLE_ADDRESS).isEnabled()) { final JsonArray address = this.fromApiJsonHelper.extractJsonArrayNamed(ClientApiConstants.address, element); baseDataValidator.reset().parameter(ClientApiConstants.address).value(address).notNull().jsonArrayNotEmpty(); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java index f22957138..bfe83b9e1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java @@ -37,6 +37,7 @@ import java.util.function.Consumer; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationProperty; import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationRepositoryWrapper; @@ -55,7 +56,6 @@ import org.apache.fineract.infrastructure.core.service.ExternalIdFactory; import org.apache.fineract.infrastructure.dataqueries.data.EntityTables; import org.apache.fineract.infrastructure.dataqueries.data.StatusEnum; import org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksWritePlatformService; -import org.apache.fineract.infrastructure.entityaccess.FineractEntityAccessConstants; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityRelation; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityRelationRepository; @@ -1760,7 +1760,7 @@ public final class LoanApplicationValidator { private void officeSpecificLoanProductValidation(final Long productId, final Long officeId) { final GlobalConfigurationProperty restrictToUserOfficeProperty = this.globalConfigurationRepository - .findOneByNameWithNotFoundDetection(FineractEntityAccessConstants.GLOBAL_CONFIG_FOR_OFFICE_SPECIFIC_PRODUCTS); + .findOneByNameWithNotFoundDetection(GlobalConfigurationConstants.OFFICE_SPECIFIC_PRODUCTS_ENABLED); if (restrictToUserOfficeProperty.isEnabled()) { FineractEntityRelation fineractEntityRelation = fineractEntityRelationRepository .findOneByCodeName(FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS.getStr()); diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index 8f7b9c640..a9e87fac4 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -167,4 +167,5 @@ + 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 cac890a89..38c4a9be1 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/fineract-provider/src/main/resources/db/changelog/tenant/parts/0149_update_global_configuration_names.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0149_update_global_configuration_names.xml new file mode 100644 index 000000000..623030632 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0149_update_global_configuration_names.xml @@ -0,0 +1,30 @@ + + + + + + UPDATE c_configuration SET name = REPLACE(REPLACE(LOWER(name), '_', '-'), ' ', '-'); + + + diff --git a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationServiceTest.java b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationServiceTest.java index d666c1d94..505a209b8 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationServiceTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/service/ExternalEventConfigurationValidationServiceTest.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant; +import org.apache.fineract.infrastructure.core.service.JdbcTemplateFactory; import org.apache.fineract.infrastructure.core.service.tenant.TenantDetailsService; import org.apache.fineract.infrastructure.event.external.exception.ExternalEventConfigurationNotFoundException; import org.apache.fineract.infrastructure.event.external.service.validation.ExternalEventSourceService; 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 8dac9a6fe..69c14f0bb 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 @@ -64,10 +64,10 @@ import org.apache.fineract.client.models.PostUpdateRescheduleLoansRequest; import org.apache.fineract.client.models.PutLoansLoanIdRequest; import org.apache.fineract.client.util.CallFailedRuntimeException; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; 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; @@ -4069,15 +4069,15 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan AtomicLong createdLoanId = new AtomicLong(); runAt("23 March 2024", () -> { // Rounding mode - HALF_DOWN - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 5); + globalConfigurationHelper.updateGlobalConfigurationInternal(GlobalConfigurationConstants.ROUNDING_MODE, 5L); createLoanForRoundingMethodValidation(true); // Rounding mode - HALF_UP - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 4); + globalConfigurationHelper.updateGlobalConfigurationInternal(GlobalConfigurationConstants.ROUNDING_MODE, 4L); createLoanForRoundingMethodValidation(false); // Rounding mode - HALF_EVEN - Default - GlobalConfigurationHelper.updateValueForGlobalConfigurationInternal(requestSpec, responseSpec, "23", 6); + globalConfigurationHelper.updateGlobalConfigurationInternal(GlobalConfigurationConstants.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 8e1b5729c..73f0778bb 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.BaseLoanIntegrationTest.TransactionProcessingStrategyCode.ADVANCED_PAYMENT_ALLOCATION_STRATEGY; import static org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder.DUE_PENALTY_INTEREST_PRINCIPAL_FEE_IN_ADVANCE_PENALTY_INTEREST_PRINCIPAL_FEE_STRATEGY; @@ -72,8 +70,10 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.BatchHelper; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -152,6 +152,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) { @@ -785,14 +786,14 @@ public abstract class BaseLoanIntegrationTest { protected void runAt(String date, Runnable runnable) { try { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 42, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + 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 0b274ff7f..25e9dccd0 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,17 @@ import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandSt 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.configuration.api.GlobalConfigurationConstants; 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 +73,10 @@ 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 BatchApiTest { +public class BatchApiTest extends BaseLoanIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(BatchApiTest.class); @@ -113,12 +111,14 @@ public class BatchApiTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); } @AfterEach public void postActions() { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(this.requestSpec, this.responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 438e141bb..08f391e23 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 @@ -38,6 +38,7 @@ import org.apache.fineract.client.models.GetObligeeData; import org.apache.fineract.client.models.PostClientsClientIdResponse; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.client.models.PutClientsClientIdResponse; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -50,6 +51,7 @@ public class ClientExternalIdTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -57,13 +59,13 @@ public class ClientExternalIdTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -92,8 +94,7 @@ public class ClientExternalIdTest { @Test public void whenAutoExternalIdConfigIsOnCreateClient() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -105,15 +106,13 @@ public class ClientExternalIdTest { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } @Test public void whenAutoExternalIdConfigIsOnCreateClientWithValue() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 +125,13 @@ public class ClientExternalIdTest { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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(GlobalConfigurationConstants.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 +199,13 @@ public class ClientExternalIdTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } @Test public void testUpdateClientUsingExternalId() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 +218,14 @@ public class ClientExternalIdTest { assertNotNull(clientUpdateResponse.getResourceExternalId()); assertEquals(clientExternalId, clientUpdateResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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(GlobalConfigurationConstants.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 +243,13 @@ public class ClientExternalIdTest { assertNotNull(clientDeleteResponse.getResourceExternalId()); assertEquals(clientExternalId, clientDeleteResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } @Test public void testGetClientAccountsUsingExternalId() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -271,15 +262,13 @@ public class ClientExternalIdTest { // then assertNotNull(clientAccountsResponse); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } @Test public void testGetClientTransferProposalDate() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 +281,13 @@ public class ClientExternalIdTest { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } @Test public void testGetClientObligeeData() { // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -313,8 +300,7 @@ public class ClientExternalIdTest { fetchClientByExternalId(clientResponse.getResourceExternalId()); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 0fba16b47..5b4ebbecb 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,14 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionI 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.configuration.api.GlobalConfigurationConstants; 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 +106,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +117,6 @@ import org.apache.fineract.portfolio.charge.domain.ChargePaymentMode; 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 +126,8 @@ import org.slf4j.LoggerFactory; * 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 +2543,7 @@ public class ClientLoanIntegrationTest { @Test public void loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEnabled() throws InterruptedException { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID); @@ -2745,8 +2742,7 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } } @@ -3446,7 +3442,9 @@ public class ClientLoanIntegrationTest { try { DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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 +3493,9 @@ public class ClientLoanIntegrationTest { HashMap loanRepayment = LOAN_TRANSACTION_HELPER.makeRepaymentWithAccountNo(loanFirstRepaymentDate, earlyPayment, accountNo); assertNotNull(loanRepayment); } finally { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -4933,7 +4933,9 @@ public class ClientLoanIntegrationTest { try { DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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 +4989,9 @@ public class ClientLoanIntegrationTest { loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } finally { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -4998,7 +5002,9 @@ public class ClientLoanIntegrationTest { 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( + GlobalConfigurationConstants.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 +5068,9 @@ public class ClientLoanIntegrationTest { 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( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -5182,7 +5190,8 @@ public class ClientLoanIntegrationTest { @Test public void chargeAdjustmentForUnpaidCharge() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +5353,16 @@ public class ClientLoanIntegrationTest { assertEquals(0.0f, loanSummary.get("principalPaid")); assertEquals(1005.0f, loanSummary.get("totalOutstanding")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void chargeAdjustmentAccountingValidation() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +5520,7 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final String feeLoanChargeDate = DATE_TIME_FORMATTER.format(targetDate); PERIODIC_ACCRUAL_ACCOUNTING_HELPER.runPeriodicAccrualAccounting(feeLoanChargeDate); @@ -5740,9 +5750,9 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, false); } } @@ -6030,8 +6040,10 @@ public class ClientLoanIntegrationTest { @Test public void chargeOff() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6288,18 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testCloseOpenMaturityDate() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6353,16 @@ public class ClientLoanIntegrationTest { assertTrue(expectedMaturityDate.isEqual(actualMaturityDate)); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testReverseReplay() { try { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6492,18 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6626,20 @@ public class ClientLoanIntegrationTest { .count()); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6758,20 @@ public class ClientLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6839,21 @@ public class ClientLoanIntegrationTest { }); } finally { - GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +6915,11 @@ public class ClientLoanIntegrationTest { .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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -8049,7 +8085,8 @@ public class ClientLoanIntegrationTest { .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 df0cfd925..097d7e251 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,7 +41,9 @@ import java.util.List; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; @@ -85,6 +87,7 @@ public class ClientSavingsIntegrationTest { private SavingsProductHelper savingsProductHelper; private SchedulerJobHelper scheduleJobHelper; private PaymentTypeHelper paymentTypeHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -94,6 +97,7 @@ public class ClientSavingsIntegrationTest { 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 +230,9 @@ public class ClientSavingsIntegrationTest { Assertions.assertNotNull(summaryAfterPosting.get("interestPostedTillDate")); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", false); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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 +248,9 @@ public class ClientSavingsIntegrationTest { List error = (List) validationErrorHelper.depositToSavingsAccount(savingsId, "3000", depositDate, CommonConstants.RESPONSE_ERROR); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "38", true); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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 +643,8 @@ public class ClientSavingsIntegrationTest { public void testSavingsAccountCharges() { Integer savingsId = null; try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate submittedDate = LocalDate.of(2022, 9, 28); String submittedDateString = "28 September 2022"; @@ -806,7 +815,8 @@ public class ClientSavingsIntegrationTest { } 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -3081,7 +3091,8 @@ public class ClientSavingsIntegrationTest { 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(GlobalConfigurationConstants.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 +3124,8 @@ public class ClientSavingsIntegrationTest { 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(GlobalConfigurationConstants.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 +3219,17 @@ public class ClientSavingsIntegrationTest { } 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( + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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 1012537ae..3cf687a90 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.security.SecureRandom; 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,8 @@ import org.apache.fineract.client.models.PostClientClientIdAddressesRequest; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -58,6 +59,7 @@ public class ClientTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private ClientHelper clientHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -66,12 +68,13 @@ public class ClientTest { 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 +206,11 @@ public class ClientTest { @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(GlobalConfigurationConstants.ENABLE_ADDRESS, + new PutGlobalConfigurationsRequest().enabled(true)); + GlobalConfigurationPropertyData updatedAddressEnabledConfig = globalConfigurationHelper + .getGlobalConfigurationByName(GlobalConfigurationConstants.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 3c1856499..c50026e8d 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,16 @@ import org.apache.fineract.client.models.GetLoansLoanIdRepaymentSchedule; 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.configuration.api.GlobalConfigurationConstants; 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 +63,12 @@ import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanSchedul 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 +91,8 @@ public class DelinquencyAndChargebackIntegrationTest { @MethodSource("loanProductFactory") public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getDateAsLocalDate("01 April 2012"); LocalDate businessDate = todaysDate.minusMonths(3); @@ -205,7 +204,8 @@ public class DelinquencyAndChargebackIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -213,7 +213,8 @@ public class DelinquencyAndChargebackIntegrationTest { @MethodSource("loanProductFactory") public void testLoanClassificationStepAsPartOfCOBRepeated(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); List expectedDates = new ArrayList(); @@ -336,7 +337,8 @@ public class DelinquencyAndChargebackIntegrationTest { } } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 23788e1fe..9ca4457d3 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,15 +63,16 @@ import org.apache.fineract.client.models.PostLoansRequest; 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; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; 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.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 +315,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { try { // Given final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 March 2012"); log.info("Current date {}", bussinesLocalDate); @@ -402,14 +404,16 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationRealtimeWithCharges() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012"); log.info("Current date {}", bussinesLocalDate); @@ -497,7 +501,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { // 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -711,7 +716,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { @Test public void testLoanClassificationJob() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = Utils.getLocalDateOfTenant(); businessDate = businessDate.minusDays(37); @@ -794,14 +800,16 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { assertEquals(secondTestCase.getClassification(), classificationExpected); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationStepAsPartOfCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012"); log.info("Current date {}", bussinesLocalDate); @@ -896,14 +904,16 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName()); assertEquals(secondTestCase.getClassification(), classificationExpected); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationToValidateNegatives() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012"); log.info("Current date {}", bussinesLocalDate); @@ -975,14 +985,16 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { assertEquals(0, getLoansLoanIdCollectionData.getPastDueDays()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanClassificationUsingAgeingArrears() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012"); log.info("Current date {}", bussinesLocalDate); @@ -1064,7 +1076,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { assertEquals(0, getLoansLoanIdCollectionData.getPastDueDays()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1394,7 +1407,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { @Test public void testLoanClassificationOnlyForActiveLoanWithCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final String operationDate = "01 January 2012"; LocalDate bussinesLocalDate = Utils.getDateAsLocalDate(operationDate); @@ -1445,7 +1459,8 @@ public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest { assertEquals(0, delinquent.getDelinquentAmount()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 26459b633..200c02ebc 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,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.PostLoansLoanIdTransactionsTransactionIdRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +53,14 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +98,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario1() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +187,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(1, response.getTransactions().get(3).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -209,7 +209,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario2() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +306,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -320,7 +322,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario3() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +426,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -437,7 +441,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario4() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +516,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(1, response.getTransactions().get(1).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -526,7 +532,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario5() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +667,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(0.0, response.getTransactions().get(secondRepaymentIndex).getOutstandingLoanBalance()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -674,7 +682,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario6() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +744,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(1, response.getTransactions().get(1).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -749,7 +759,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario7() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +880,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(1, response.getTransactions().get(2).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -884,7 +896,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario8() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +1103,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(1, response.getTransactions().get(4).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1108,7 +1122,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario9() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +1415,8 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(2, response.getTransactions().get(5).getLoanChargePaidByList().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1414,10 +1430,12 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario10() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); final Account assetAccount = this.accountHelper.createAssetAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount(); @@ -1593,8 +1611,10 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { assertEquals(0.0, loanDetails.getTransactions().get(4).getOutstandingLoanBalance()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(requestSpec, responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -1608,10 +1628,12 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { @Test public void scenario11() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); final Account assetAccount = this.accountHelper.createAssetAccount(); final Account incomeAccount = this.accountHelper.createIncomeAccount(); @@ -1787,8 +1809,10 @@ public class DueDateRespectiveLoanRepaymentScheduleTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 66899514b..8ddcf75b6 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.assertNotNull; 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,36 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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(GlobalConfigurationConstants.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 +664,8 @@ public class ExternalIdSupportIntegrationTest extends IntegrationTest { response = loanTransactionHelper.getLoanTransactionDetails(loanExternalIdStr, payChargeExternalIdStr); assertEquals(payChargeExternalIdStr, response.getExternalId()); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(false)); } @Test @@ -854,8 +828,10 @@ public class ExternalIdSupportIntegrationTest extends IntegrationTest { @Test public void loan() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, true); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +1081,10 @@ public class ExternalIdSupportIntegrationTest extends IntegrationTest { assertEquals(transactionExternalId3, chargeOffResult.getResourceExternalId()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 50, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 7ca4884d4..e14145913 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,8 @@ import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; @@ -52,6 +54,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest { private RequestSpecification requestSpec; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +64,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest { 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 +75,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest { Assertions.assertNotNull(clientID); // Configuring global config flags - configureInterestPosting(true, 4); + configureInterestPosting(true, 4L); final Integer savingsId = createSavingsAccount(clientID, startDate); @@ -108,36 +112,16 @@ public class FlexibleSavingsInterestPostingIntegrationTest { 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 = GlobalConfigurationConstants.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 = GlobalConfigurationConstants.FINANCIAL_YEAR_BEGINNING_MONTH; + globalConfigurationHelper.updateGlobalConfiguration(financialYearBeginningConfigName, + new PutGlobalConfigurationsRequest().value(financialYearBeginningMonth)); } private Integer createSavingsProduct() { @@ -149,8 +133,8 @@ public class FlexibleSavingsInterestPostingIntegrationTest { // 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 bbb539aed..000000000 --- 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 d536a396a..273c613bd 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,20 @@ */ 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.AfterEach; @@ -40,7 +46,6 @@ public class GlobalConfigurationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private GlobalConfigurationHelper globalConfigurationHelper; - private ResponseSpecification httpStatusForidden; @BeforeEach public void setup() { @@ -48,205 +53,58 @@ public class GlobalConfigurationTest { 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); + final GetGlobalConfigurationsResponse globalConfig = globalConfigurationHelper.getAllGlobalConfigurations(); 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 testGlobalConfigurationUpdate() { + String configName = GlobalConfigurationConstants.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 testGlobalConfigurationsEnableDisable() { - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); + public void testPasswordUpdateFailing() { + String configName = GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS; + GlobalConfigurationPropertyData config = globalConfigurationHelper.getGlobalConfigurationByName(configName); + Assertions.assertNotNull(config); - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - 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"); - } - } - - @Test - public void testGlobalConfigForcePasswordResetDays() { - - // Retrieving All Global Configuration details - final ArrayList globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, this.responseSpec); - Assertions.assertNotNull(globalConfig); - - 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); - - 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 5609a9ada..380382a29 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,34 @@ import io.restassured.http.ContentType; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +64,6 @@ public class LoanAccountArrearsAgeingCOBBusinessStepTest { 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 +72,8 @@ public class LoanAccountArrearsAgeingCOBBusinessStepTest { public void loanArrearsAgeingCOBBusinessStepTest() { // Set Business Date try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate businessDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); @@ -148,7 +140,8 @@ public class LoanAccountArrearsAgeingCOBBusinessStepTest { assertEquals(loan2Summary.getPrincipalOverdue(), 1000.00); assertEquals(loan2Summary.getTotalOverdue(), 1000.00); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 e367b68c1..41d7767dd 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,20 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; 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.configuration.api.GlobalConfigurationConstants; 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 +72,8 @@ public class LoanAccountBackdatedDisbursementTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -282,7 +281,8 @@ public class LoanAccountBackdatedDisbursementTest { assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -293,7 +293,8 @@ public class LoanAccountBackdatedDisbursementTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -494,7 +495,8 @@ public class LoanAccountBackdatedDisbursementTest { assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -505,7 +507,8 @@ public class LoanAccountBackdatedDisbursementTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -758,7 +761,8 @@ public class LoanAccountBackdatedDisbursementTest { assertEquals(false, loanDetails.getRepaymentSchedule().getPeriods().get(6).getComplete()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -771,7 +775,8 @@ public class LoanAccountBackdatedDisbursementTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -864,7 +869,8 @@ public class LoanAccountBackdatedDisbursementTest { loanErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -875,7 +881,8 @@ public class LoanAccountBackdatedDisbursementTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -1053,7 +1060,8 @@ public class LoanAccountBackdatedDisbursementTest { 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(GlobalConfigurationConstants.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 52194eb57..57ab37509 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.LocalDate; 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.PostPaymentTypesRequest; 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 class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest { 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 @@ public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest { 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 72f169d28..232ca5d51 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,20 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; 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.configuration.api.GlobalConfigurationConstants; 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 +73,8 @@ public class LoanAccountOverpaidDateStatusTest { try { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); // Loan ExternalId @@ -159,7 +158,8 @@ public class LoanAccountOverpaidDateStatusTest { assertNotNull(loanDetailsOverpaid_3.getOverpaidOnDate()); assertEquals(loanDetailsOverpaid_3.getOverpaidOnDate(), LocalDate.of(2022, 9, 14)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 34f17cf22..af8b4632d 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,30 @@ import java.time.LocalDate; 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.configuration.api.GlobalConfigurationConstants; 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 +86,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -245,7 +239,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -264,7 +259,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -421,7 +417,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -438,7 +435,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -613,7 +611,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -631,7 +630,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -809,7 +809,8 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe false, LocalDate.of(2023, 4, 3), LocalDate.of(2023, 5, 3)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -881,31 +882,6 @@ public class LoanAccountPaymentAllocationWithOverlappingDownPaymentInstallmentTe 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 63dfc7d22..fdb618b58 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,19 @@ import java.util.UUID; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +68,8 @@ public class LoanAccountRepaymentCalculationTest { // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -151,7 +150,8 @@ public class LoanAccountRepaymentCalculationTest { LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -163,7 +163,8 @@ public class LoanAccountRepaymentCalculationTest { // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -244,7 +245,8 @@ public class LoanAccountRepaymentCalculationTest { LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -256,7 +258,8 @@ public class LoanAccountRepaymentCalculationTest { // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -322,7 +325,8 @@ public class LoanAccountRepaymentCalculationTest { LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -334,7 +338,8 @@ public class LoanAccountRepaymentCalculationTest { // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Loan ExternalId @@ -400,7 +405,8 @@ public class LoanAccountRepaymentCalculationTest { LocalDate.of(2023, 6, 3), false); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 caa85a2bf..fab744153 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 @@ -28,8 +28,8 @@ import lombok.extern.slf4j.Slf4j; import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse; import org.apache.fineract.client.models.GetClientsLoanAccounts; import org.apache.fineract.client.models.PostClientsResponse; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Slf4j -public class LoanAccountsContainsCurrencyFieldTest { +public class LoanAccountsContainsCurrencyFieldTest extends BaseLoanIntegrationTest { private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -65,8 +65,7 @@ public class LoanAccountsContainsCurrencyFieldTest { String formattedDate = "01 September 2022"; // given - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); final String jsonPayload = ClientHelper.getBasicClientAsJSON(ClientHelper.DEFAULT_OFFICE_ID, ClientHelper.LEGALFORM_ID_PERSON, null); // when @@ -74,8 +73,7 @@ public class LoanAccountsContainsCurrencyFieldTest { final String clientExternalId = clientResponse.getResourceExternalId(); final long clientId = clientResponse.getClientId(); - GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 4ba40865e..c57bafc81 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,12 @@ import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod; 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.configuration.api.GlobalConfigurationConstants; 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 +61,7 @@ import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; 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 +99,14 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -146,7 +149,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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 +177,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -192,12 +197,14 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -241,7 +248,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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 +276,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -286,12 +295,14 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -337,7 +348,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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 +377,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -383,12 +396,14 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -432,7 +447,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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 +475,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -477,12 +494,14 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -529,8 +548,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { checkAccrualTransactionsForMultipleRepaymentSchedulesChargeDueDate(currentDate, loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -546,11 +567,13 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -588,7 +611,7 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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 +622,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } } @@ -617,9 +642,11 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { // Set business date LocalDate currentDate = LocalDate.of(2023, 05, 19); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Loan ExternalId String loanExternalIdStr = UUID.randomUUID().toString(); @@ -721,8 +748,10 @@ public class LoanAccrualTransactionOnChargeSubmittedDateTest { verifyPeriodDates(periods); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "due-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 f2d985d2c..1f9f4b5d2 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,12 @@ import org.apache.fineract.client.models.GetDelinquencyBucketsResponse; 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.configuration.api.GlobalConfigurationConstants; 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 +50,12 @@ import org.apache.fineract.integrationtests.common.accounting.PeriodicAccrualAcc 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 +140,8 @@ public class LoanAccrualTransactionReversalTest { LocalDate currentDate = LocalDate.of(2022, 05, 8); final String accrualRunTillDate = dateFormatter.format(currentDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); // Accounts oof periodic accrual @@ -176,7 +175,8 @@ public class LoanAccrualTransactionReversalTest { // 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(GlobalConfigurationConstants.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 87d6a87aa..227c8657e 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,9 @@ import org.apache.fineract.client.models.PostLoanProductsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +42,8 @@ public class LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOn try { // Configure Charge accrual date as submitted on date - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -102,7 +104,8 @@ public class LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOn 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(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("due-date")); } }); @@ -115,7 +118,8 @@ public class LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOn try { // Configure Charge accrual date as submitted on date - GlobalConfigurationHelper.updateChargeAccrualDateConfiguration(this.requestSpec, this.responseSpec, "submitted-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE, + new PutGlobalConfigurationsRequest().stringValue("submitted-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -200,7 +204,8 @@ public class LoanAccrualTransactionWithInterestAndChargeAccrualDateAsSubmittedOn 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(GlobalConfigurationConstants.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 f68accb80..e4096d91a 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,12 @@ import java.util.ArrayList; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +45,14 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +76,11 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { @Test public void testCatchUpInLockedInstanceLastCOBDateIsNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -126,17 +126,21 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testInlineCOBInLockedInstanceLastCOBDateIsNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -181,17 +185,21 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testCatchUpInLockedInstanceLastCOBDateIsNotNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -255,17 +263,21 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testInlineCOBInLockedInstanceLastCOBDateIsNotNull() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -313,17 +325,21 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBNoLock() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.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 +384,21 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBWithLoanAccountLockedWithInlineCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.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 +445,10 @@ public class LoanCOBAccountLockCatchupInlineCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 ba0a1dd46..81e04cb80 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,11 @@ import io.restassured.http.ContentType; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +45,7 @@ import org.junit.jupiter.api.extension.ExtendWith; @Order(1) @ExtendWith(InstanceModeSupportExtension.class) -public class LoanCOBCatchUpInstanceModeIntegrationTest { +public class LoanCOBCatchUpInstanceModeIntegrationTest extends BaseLoanIntegrationTest { private LoanCOBCatchUpHelper loanCOBCatchUpHelper; private ResponseSpecification responseSpec; @@ -62,7 +63,8 @@ public class LoanCOBCatchUpInstanceModeIntegrationTest { schedulerJobHelper = new SchedulerJobHelper(requestSpec); originalSchedulerStatus = schedulerJobHelper.getSchedulerStatus(); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); } @@ -122,7 +124,8 @@ public class LoanCOBCatchUpInstanceModeIntegrationTest { @AfterEach public void tearDown() throws InterruptedException { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 62f5d962b..48e4aa8a3 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,13 @@ import java.util.List; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +46,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +53,8 @@ import org.apache.http.HttpStatus; 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 +79,11 @@ public class LoanCatchUpIntegrationTest { @Test public void testCatchUpInLockedInstance() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -146,8 +146,10 @@ public class LoanCatchUpIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 81462b81e..78c0bea50 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,12 @@ import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdRequest; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +51,13 @@ import org.apache.fineract.integrationtests.common.accounting.PeriodicAccrualAcc 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 +688,8 @@ public class LoanChargeOffAccountingTest { @Test public void noIncomeRecognitionAfterChargeOff() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +784,8 @@ public class LoanChargeOffAccountingTest { assertTrue(loanDetails.getTransactions().get(5).getType().getRepayment()); assertEquals(6, loanDetails.getTransactions().size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 5b216a346..4f7aa29eb 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,13 @@ import org.apache.fineract.client.models.PostClientsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +59,6 @@ import org.apache.fineract.integrationtests.common.accounting.FinancialActivityA 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 +71,9 @@ import org.junit.jupiter.api.AfterAll; 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 +167,8 @@ public class LoanChargePaymentWithAdvancedPaymentAllocationTest { final String jobName = "Transfer Fee For Loans From Savings"; final String startDate = "10 April 2022"; - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +236,8 @@ public class LoanChargePaymentWithAdvancedPaymentAllocationTest { 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(GlobalConfigurationConstants.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 442354da0..b6220c5b6 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,11 @@ import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +56,12 @@ import org.apache.fineract.integrationtests.common.accounting.PeriodicAccrualAcc 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 +236,8 @@ public class LoanChargeSpecificDueDateTest { @Test public void testApplyAndWaiveInstallmentFee() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -311,7 +310,8 @@ public class LoanChargeSpecificDueDateTest { @Test public void testApplyAndWaiveInstallmentFeeAnotherDueDate() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -450,7 +450,8 @@ public class LoanChargeSpecificDueDateTest { @Test public void testApplyFeeAccrualOnClosedDate() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -576,14 +577,16 @@ public class LoanChargeSpecificDueDateTest { assertEquals(transactionDate, journalEntries.get(0).getTransactionDate()); assertEquals(transactionDate, journalEntries.get(1).getTransactionDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testApplyFeeAccrualWhenLoanOverpaid() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -654,7 +657,8 @@ public class LoanChargeSpecificDueDateTest { assertEquals(transactionDate, journalEntries.get(0).getTransactionDate()); assertEquals(transactionDate, journalEntries.get(1).getTransactionDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 af8a09846..ab004105c 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,16 @@ import io.restassured.http.ContentType; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +45,10 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +76,8 @@ public class LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocat // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 15); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BusinessDateType.BUSINESS_DATE, businessDate); // Accounts oof periodic accrual @@ -122,7 +120,8 @@ public class LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocat loanChargeErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -139,31 +138,6 @@ public class LoanChargeTypeInstallmentFeeErrorHandlingWithAdvancedPaymentAllocat } - 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 1cdc11f1e..f12d6b3db 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,9 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +49,8 @@ public class LoanDelinquencyDetailsNextPaymentDateConfigurationTest extends Base runAt("01 November 2023", () -> { try { // update Global configuration for next payment date - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "next-unpaid-due-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE, + new PutGlobalConfigurationsRequest().stringValue("next-unpaid-due-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -122,8 +123,8 @@ public class LoanDelinquencyDetailsNextPaymentDateConfigurationTest extends Base } finally { // reset global config - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "earliest-unpaid-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE, + new PutGlobalConfigurationsRequest().stringValue("earliest-unpaid-date")); } }); @@ -134,8 +135,8 @@ public class LoanDelinquencyDetailsNextPaymentDateConfigurationTest extends Base runAt("01 November 2023", () -> { try { // update Global configuration for next payment date - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "next-unpaid-due-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE, + new PutGlobalConfigurationsRequest().stringValue("next-unpaid-due-date")); // Create Client Long clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId(); @@ -237,8 +238,8 @@ public class LoanDelinquencyDetailsNextPaymentDateConfigurationTest extends Base .dateFormat(DATETIME_PATTERN).locale("en")); } finally { // reset global config - GlobalConfigurationHelper.updateLoanNextPaymentDateConfiguration(this.requestSpec, this.responseSpec, - "earliest-unpaid-date"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 cef95ea9d..7dff5b0a9 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,12 @@ import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod; 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.configuration.api.GlobalConfigurationConstants; 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 +53,11 @@ import org.apache.fineract.integrationtests.common.accounting.PeriodicAccrualAcc 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 +90,10 @@ public class LoanMultipleDisbursementRepaymentScheduleTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); // Loan ExternalId @@ -124,7 +123,7 @@ public class LoanMultipleDisbursementRepaymentScheduleTest { // run cob - currentDate = LocalDate.of(2023, 07, 12); + currentDate = LocalDate.of(2023, 7, 12); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, currentDate); @@ -136,7 +135,7 @@ public class LoanMultipleDisbursementRepaymentScheduleTest { // 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 +149,7 @@ public class LoanMultipleDisbursementRepaymentScheduleTest { 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 +168,8 @@ public class LoanMultipleDisbursementRepaymentScheduleTest { assertEquals(1, activePeriods); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 5cbf0e594..ae25f0f42 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,9 +32,11 @@ 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.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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; @@ -52,6 +54,7 @@ public class LoanProductRepaymentStartDateConfigurationTest { private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; private ClientHelper clientHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +64,7 @@ public class LoanProductRepaymentStartDateConfigurationTest { 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 +130,8 @@ public class LoanProductRepaymentStartDateConfigurationTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -265,7 +270,8 @@ public class LoanProductRepaymentStartDateConfigurationTest { assertEquals(500.00, loanDetails.getRepaymentSchedule().getPeriods().get(4).getTotalInstallmentAmountForPeriod()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -280,7 +286,8 @@ public class LoanProductRepaymentStartDateConfigurationTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); // Loan ExternalId @@ -422,7 +429,8 @@ public class LoanProductRepaymentStartDateConfigurationTest { assertEquals(333.34, loanDetails.getRepaymentSchedule().getPeriods().get(4).getTotalInstallmentAmountForPeriod()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 253fc7b69..e6a8deba9 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,14 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; 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.configuration.api.GlobalConfigurationConstants; 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 +818,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio @Test public void testDelinquencyRangeOnDownPaymentInstallment() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +873,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio } finally { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -991,7 +994,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Accounts oof periodic accrual @@ -1098,7 +1102,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio new JournalEntry(50, JournalEntry.TransactionType.DEBIT)); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -1110,7 +1115,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio // Set business date LocalDate disbursementDate = LocalDate.of(2023, 3, 3); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, disbursementDate); // Accounts oof periodic accrual @@ -1165,7 +1171,8 @@ public class LoanRepaymentScheduleWithDownPaymentTest extends BaseLoanIntegratio checkNoDownPaymentTransaction(loanId); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 058e1ba08..20d16be96 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,24 @@ import java.util.HashMap; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +283,18 @@ public class LoanRescheduleOnDecliningBalanceLoanTest { * 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( + GlobalConfigurationConstants.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( + GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI, + new PutGlobalConfigurationsRequest().enabled(false)); } @Test @@ -543,14 +545,18 @@ public class LoanRescheduleOnDecliningBalanceLoanTest { * enables the configuration `is-principal-compounding-disabled-for-overdue-loans` **/ private void enablePrincipalCompoundingConfig() { - GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, "43", true); + globalConfigurationHelper.updateGlobalConfiguration( + GlobalConfigurationConstants.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( + GlobalConfigurationConstants.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 0a7864a52..73f148751 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,23 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +85,36 @@ public class LoanRescheduleWithAdvancePaymentTest { * 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( + GlobalConfigurationConstants.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( + GlobalConfigurationConstants.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( + GlobalConfigurationConstants.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( + GlobalConfigurationConstants.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 77942fa15..38727e57b 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.CenterDomain; 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.accounting.Account; 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 class LoanReschedulingWithinCenterTest { 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 660f7e19b..d6408afd7 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,11 @@ import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +61,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.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 +68,11 @@ import org.apache.fineract.portfolio.charge.domain.ChargePaymentMode; 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 +434,8 @@ public class LoanSpecificDueDateChargeAfterMaturityTest { @Test public void addChargeAfterLoanMaturity() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +507,8 @@ public class LoanSpecificDueDateChargeAfterMaturityTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -590,13 +590,4 @@ public class LoanSpecificDueDateChargeAfterMaturityTest { 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 0fb211c96..3327b9a46 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,27 @@ import org.apache.fineract.client.models.GetLoansLoanIdTransactions; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +196,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { @MethodSource("loanProductFactory") public void applyLoanTransactionChargebackInLongTermLoan(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +250,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { } finally { final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -279,7 +279,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { @MethodSource("loanProductFactory") public void applyLoanTransactionChargebackAfterMature(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); final LocalDate todaysDate = Utils.getLocalDateOfTenant(); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); @@ -383,7 +384,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 4, Double.valueOf("800.00")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -524,7 +526,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { @MethodSource("loanProductFactory") public void applyMultipleLoanTransactionChargeback(LoanProductTestBuilder loanProductTestBuilder) { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +589,8 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest { DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 0, Double.valueOf("0.00")); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 90b4da6e2..92774f3b5 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,17 @@ import java.time.LocalDate; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +50,10 @@ import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuil 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 +79,8 @@ public class LoanTransactionReprocessForAdvancedPaymentAllocationTest { // Set business date LocalDate businessDate = LocalDate.of(2023, 3, 15); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BusinessDateType.BUSINESS_DATE, businessDate); // Accounts oof periodic accrual @@ -164,7 +161,8 @@ public class LoanTransactionReprocessForAdvancedPaymentAllocationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -181,31 +179,6 @@ public class LoanTransactionReprocessForAdvancedPaymentAllocationTest { } - 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 f73ff45a3..89a737582 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,11 @@ import org.apache.fineract.client.models.GetLoansLoanIdTransactions; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +53,13 @@ import org.apache.fineract.integrationtests.common.accounting.JournalEntryHelper 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 +95,8 @@ public class LoanTransactionReverseReplayTest { @Test public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesTest() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +146,8 @@ public class LoanTransactionReverseReplayTest { assertTrue(loansLoanIdResponse.getTransactions().get(lastTransactionIndex).getType().getAccrual()); assertEquals(10.0, loansLoanIdResponse.getTransactions().get(lastTransactionIndex).getAmount()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -160,7 +160,8 @@ public class LoanTransactionReverseReplayTest { @Test public void loanTransactionReverseReplayWithAdditionalInstallmentAndChargesScheduleDueDateTest() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +227,16 @@ public class LoanTransactionReverseReplayTest { assertEquals(LocalDate.of(2022, 10, 11), loansLoanIdResponse.getRepaymentSchedule().getPeriods().get(lastPeriodIndex).getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void loanTransactionReverseReplayWithChargeOffAndCBR() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +359,8 @@ public class LoanTransactionReverseReplayTest { assertEquals(1, cbrExpenseJournalEntries.size()); assertEquals(1, cbrAssetJournalEntries.size()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 b3480ce59..1e96e3efb 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,8 +30,9 @@ import io.restassured.specification.ResponseSpecification; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.AuditHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; @@ -58,6 +59,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 +72,7 @@ public class MakercheckerTest { 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 +85,11 @@ public class MakercheckerTest { @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(GlobalConfigurationConstants.MAKER_CHECKER, + new PutGlobalConfigurationsRequest().enabled(true)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_SAME_MAKER_CHECKER, + new PutGlobalConfigurationsRequest().enabled(false)); try { // client permission - maker-checker disabled @@ -190,12 +182,13 @@ public class MakercheckerTest { 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(GlobalConfigurationConstants.MAKER_CHECKER, + new PutGlobalConfigurationsRequest().enabled(false)); + + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 1ff910c90..4581af38f 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,16 @@ import org.apache.fineract.client.models.PostClientsResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +59,9 @@ import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanSchedul 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 +90,8 @@ public class RefundForActiveLoansWithAdvancedPaymentAllocationTest { @Test public void refundForActiveLoanWithDefaultPaymentAllocationProcessingVertically() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +283,16 @@ public class RefundForActiveLoansWithAdvancedPaymentAllocationTest { assertEquals(250.0f, thirdRepaymentInstallment.getTotalOutstandingForPeriod()); assertEquals(LocalDate.of(2023, 4, 1), thirdRepaymentInstallment.getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void refundForActiveLoanWithDefaultPaymentAllocationProcessingHorizontally() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +485,8 @@ public class RefundForActiveLoansWithAdvancedPaymentAllocationTest { assertEquals(250.0f, thirdRepaymentInstallment.getTotalOutstandingForPeriod()); assertEquals(LocalDate.of(2023, 4, 1), thirdRepaymentInstallment.getDueDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 4ae61978b..5616f3aa2 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 class SavingsAccountRecalculateBalanceTest { 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 @@ public class SavingsAccountRecalculateBalanceTest { @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 0f4f666d5..711719a4a 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 class SavingsAccountTransactionDatatableIntegrationTest { 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 @@ public class SavingsAccountTransactionDatatableIntegrationTest { // 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 d643d23ff..9fd39870c 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.assertNotNull; 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,7 +55,9 @@ import java.util.stream.Collectors; 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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BatchHelper; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -91,6 +92,7 @@ public class SavingsAccountTransactionTest { private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; private DatatableHelper datatableHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -103,13 +105,15 @@ public class SavingsAccountTransactionTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, today); LocalDate depositDate = Utils.getDateAsLocalDate(depositDateString); @@ -124,7 +128,8 @@ public class SavingsAccountTransactionTest { performSavingsTransaction(savingsId, "100", depositDate, true); performSavingsTransaction(savingsId, "50", withdrawDate, false); } finally { - enableBusinessDate(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -277,10 +282,6 @@ public class SavingsAccountTransactionTest { 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 +457,7 @@ public class SavingsAccountTransactionTest { // 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 65f9e5b01..e97a9293a 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,8 +36,10 @@ import java.util.Locale; 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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.MathUtil; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -76,6 +78,7 @@ public class SavingsAccountTransactionsSearchIntegrationTest { private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; private SavingsAccountHelper savingsAccountHelperValidationError; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -87,6 +90,7 @@ public class SavingsAccountTransactionsSearchIntegrationTest { 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 +171,16 @@ public class SavingsAccountTransactionsSearchIntegrationTest { final Integer savingsId = createSavingsAccountDailyPosting(clientID, startDate); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } String submittedDate = DateUtils.format(businessDate, DEFAULT_DATE_FORMAT, DEFAULT_LOCALE); TransactionSearchRequest searchParameters = new TransactionSearchRequest() @@ -454,8 +460,8 @@ public class SavingsAccountTransactionsSearchIntegrationTest { // 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 16b6411e6..9fb187c3f 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,7 +32,9 @@ import java.util.HashMap; 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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -59,6 +61,7 @@ public class SavingsInterestPostingIntegrationTest { private RequestSpecification requestSpec; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -68,13 +71,15 @@ public class SavingsInterestPostingIntegrationTest { 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(GlobalConfigurationConstants.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 +107,8 @@ public class SavingsInterestPostingIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -129,8 +135,8 @@ public class SavingsInterestPostingIntegrationTest { // 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 2f77b7c1b..93dd71f13 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,7 +32,9 @@ import java.util.HashMap; 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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -68,6 +70,7 @@ public class SavingsInterestPostingJobIntegrationTest { private SchedulerJobHelper scheduleJobHelper; private JournalEntryHelper journalEntryHelper; private AccountHelper accountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -78,6 +81,7 @@ public class SavingsInterestPostingJobIntegrationTest { this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); this.savingsProductHelper = new SavingsProductHelper(); this.scheduleJobHelper = new SchedulerJobHelper(requestSpec); + this.globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -149,7 +153,8 @@ public class SavingsInterestPostingJobIntegrationTest { public void testSavingsDailyInterestPostingJob() { LocalDate today = Utils.getLocalDateOfTenant(); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +183,8 @@ public class SavingsInterestPostingJobIntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -318,8 +324,8 @@ public class SavingsInterestPostingJobIntegrationTest { // 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 f3925d2c8..d64af4bb6 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,15 @@ import static org.awaitility.Awaitility.await; 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.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.jobs.service.JobName; import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; @@ -47,6 +47,7 @@ public class SchedulerJobsTest { private RequestSpecification requestSpec; private SchedulerJobHelper schedulerJobHelper; private Boolean originalSchedulerStatus; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -61,6 +62,7 @@ public class SchedulerJobsTest { Boolean active = (Boolean) schedulerJob.get("active"); originalJobStatus.put(jobId, active); } + globalConfigurationHelper = new GlobalConfigurationHelper(); } @AfterEach @@ -135,14 +137,15 @@ public class SchedulerJobsTest { @Test public void testTriggeringManualExecutionOfAllSchedulerJobs() { - ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); for (String jobName : schedulerJobHelper.getAllSchedulerJobNames()) { schedulerJobHelper.executeAndAwaitJob(jobName); } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 89f92d32d..791c26257 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,8 +56,10 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.BusinessStepHelper; import org.apache.fineract.integrationtests.common.ClientHelper; @@ -124,6 +126,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 +150,21 @@ public class SchedulerJobsTestResults { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); LocalDate submittedDate = LocalDate.of(2022, 9, 28); String submittedDateString = "28 September 2022"; @@ -211,7 +216,8 @@ public class SchedulerJobsTestResults { .isEquivalentAccordingToCompareTo(expectedDueDate); } finally { savingsAccountHelper.closeSavingsAccountOnDate(savingsId, "true", "11 November 2022"); - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -343,24 +349,10 @@ public class SchedulerJobsTestResults { 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 = GlobalConfigurationConstants.RESCHEDULE_REPAYMENTS_ON_HOLIDAYS; + globalConfigurationHelper.updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().enabled(true)); holidayId = HolidayHelper.activateHolidays(requestSpec, responseSpec, holidayId.toString()); Assertions.assertNotNull(holidayId); @@ -457,24 +449,8 @@ public class SchedulerJobsTestResults { 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 = GlobalConfigurationConstants.RESCHEDULE_REPAYMENTS_ON_HOLIDAYS; + globalConfigurationHelper.updateGlobalConfiguration(configName, new PutGlobalConfigurationsRequest().enabled(true)); holidayId = HolidayHelper.activateHolidays(requestSpec, responseSpec, holidayId.toString()); Assertions.assertNotNull(holidayId); @@ -877,7 +853,8 @@ public class SchedulerJobsTestResults { @Test public void testLoanCOBJobOutcome() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); this.savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -937,14 +914,16 @@ public class SchedulerJobsTestResults { } } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBJobOutcomeWhileAddingFeeOnDisbursementDate() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +982,16 @@ public class SchedulerJobsTestResults { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBRunsOnlyOnLoansOneDayBehind() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -1058,17 +1039,20 @@ public class SchedulerJobsTestResults { loan = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanID); Assertions.assertEquals(LocalDate.of(2020, 7, 3), loan.getLastClosedBusinessDate()); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testLoanCOBApplyPenaltyOnDue() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -1118,18 +1102,22 @@ public class SchedulerJobsTestResults { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @Test public void testLoanCOBApplyPenaltyOnDue1DayGracePeriod() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -1158,7 +1146,8 @@ public class SchedulerJobsTestResults { JsonPath.from(loanDetails2).get("netDisbursalAmount").toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec, "10", "1"); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +1169,10 @@ public class SchedulerJobsTestResults { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(2L)); } } @@ -1356,7 +1347,8 @@ public class SchedulerJobsTestResults { public void businessDateIsCorrectForCronJob() throws InterruptedException { this.loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +1392,8 @@ public class SchedulerJobsTestResults { 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(GlobalConfigurationConstants.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 36a3d551b..266ad381f 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,9 @@ import java.util.ArrayList; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.CalendarHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; @@ -58,7 +61,6 @@ public class SkipRepaymentOnMonthFirstTest { private RequestSpecification requestSpec; private GlobalConfigurationHelper globalConfigurationHelper; private LoanTransactionHelper loanTransactionHelper; - private CalendarHelper calendarHelper; @BeforeEach public void setup() { @@ -66,39 +68,26 @@ public class SkipRepaymentOnMonthFirstTest { 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( + GlobalConfigurationConstants.SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH, + 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 ad982b23b..0cf72e930 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.LocalDate; 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,17 @@ import org.apache.fineract.client.models.GetLoanFeeToIncomeAccountMappings; import org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; -import org.apache.fineract.client.models.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.infrastructure.configuration.api.GlobalConfigurationConstants; 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 +62,15 @@ 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 UndoRepaymentWithDownPaymentIntegrationTest { +public class UndoRepaymentWithDownPaymentIntegrationTest extends BaseLoanIntegrationTest { private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); private ResponseSpecification responseSpec; @@ -147,7 +141,8 @@ public class UndoRepaymentWithDownPaymentIntegrationTest { @Test public void undoRepaymentWithDownPaymentAndAdvancedPaymentAllocationTest() { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); String loanExternalIdStr = UUID.randomUUID().toString(); @@ -365,29 +360,4 @@ public class UndoRepaymentWithDownPaymentIntegrationTest { 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 084c9e4b3..f9bc9d18d 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,13 @@ import lombok.extern.slf4j.Slf4j; 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.infrastructure.configuration.api.GlobalConfigurationConstants; +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 +58,15 @@ import org.apache.fineract.integrationtests.common.loans.CobHelper; 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 +118,7 @@ public class CobPartitioningTest { 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(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); List loanIds = new CopyOnWriteArrayList<>(); @@ -192,9 +190,11 @@ public class CobPartitioningTest { } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); } private void cleanUpAndRestoreBusinessDate() { @@ -203,9 +203,9 @@ public class CobPartitioningTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 98049242c..51f6fb0ae 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,46 @@ import static org.junit.jupiter.api.Assertions.assertEquals; 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.infrastructure.configuration.api.GlobalConfigurationConstants; +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 +78,11 @@ public class GlobalConfigurationHelper { // 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 +90,30 @@ public class GlobalConfigurationHelper { 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"), + 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("enabled"), actualGlobalConfiguration.get("enabled"), - assertionFailedMessage); - Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.get("trapDoor"), + Assertions.assertEquals(expectedGlobalConfiguration.get("trapDoor"), actualGlobalConfiguration.getTrapDoor(), assertionFailedMessage); } } @@ -153,447 +132,397 @@ public class GlobalConfigurationHelper { ArrayList defaults = new ArrayList<>(); HashMap makerCheckerDefault = new HashMap<>(); - makerCheckerDefault.put("id", 1); - makerCheckerDefault.put("name", "maker-checker"); - makerCheckerDefault.put("value", 0); + makerCheckerDefault.put("name", GlobalConfigurationConstants.MAKER_CHECKER); + 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("name", GlobalConfigurationConstants.AMAZON_S3); + 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("name", GlobalConfigurationConstants.RESCHEDULE_FUTURE_REPAYMENTS); + rescheduleFuturePaymentsDefault.put("value", 0L); rescheduleFuturePaymentsDefault.put("enabled", true); rescheduleFuturePaymentsDefault.put("trapDoor", false); defaults.add(rescheduleFuturePaymentsDefault); HashMap rescheduleRepaymentsOnHolidaysDefault = new HashMap<>(); rescheduleRepaymentsOnHolidaysDefault.put("id", 6); - rescheduleRepaymentsOnHolidaysDefault.put("name", "reschedule-repayments-on-holidays"); - rescheduleRepaymentsOnHolidaysDefault.put("value", 0); + rescheduleRepaymentsOnHolidaysDefault.put("name", GlobalConfigurationConstants.RESCHEDULE_REPAYMENTS_ON_HOLIDAYS); + 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("name", GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_HOLIDAY); + 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("name", GlobalConfigurationConstants.ALLOW_TRANSACTIONS_ON_NON_WORKING_DAY); + 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("name", GlobalConfigurationConstants.CONSTRAINT_APPROACH_FOR_DATATABLES); + 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("name", GlobalConfigurationConstants.PENALTY_WAIT_PERIOD); + 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("name", GlobalConfigurationConstants.FORCE_PASSWORD_RESET_DAYS); + 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("name", GlobalConfigurationConstants.GRACE_ON_PENALTY_POSTING); + 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("name", GlobalConfigurationConstants.SAVINGS_INTEREST_POSTING_CURRENT_PERIOD_END); + 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("name", GlobalConfigurationConstants.FINANCIAL_YEAR_BEGINNING_MONTH); + 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("name", GlobalConfigurationConstants.MIN_CLIENTS_IN_GROUP); + 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("name", GlobalConfigurationConstants.MAX_CLIENTS_IN_GROUP); + 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("name", GlobalConfigurationConstants.MEETINGS_MANDATORY_FOR_JLG_LOANS); + 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("name", GlobalConfigurationConstants.OFFICE_SPECIFIC_PRODUCTS_ENABLED); + 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("name", GlobalConfigurationConstants.RESTRICT_PRODUCTS_TO_USER_OFFICE); + 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("name", GlobalConfigurationConstants.OFFICE_OPENING_BALANCES_CONTRA_ACCOUNT); + 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("name", GlobalConfigurationConstants.ROUNDING_MODE); + 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("name", GlobalConfigurationConstants.BACKDATE_PENALTIES_ENABLED); + 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("name", GlobalConfigurationConstants.ORGANISATION_START_DATE); + 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("name", + GlobalConfigurationConstants.PAYMENT_TYPE_APPLICABLE_FOR_DISBURSEMENT_CHARGES); + 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("name", + GlobalConfigurationConstants.INTEREST_CHARGED_FROM_DATE_SAME_AS_DISBURSAL_DATE); + 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("name", GlobalConfigurationConstants.SKIP_REPAYMENT_ON_FIRST_DAY_OF_MONTH); + 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("name", + GlobalConfigurationConstants.CHANGE_EMI_IF_REPAYMENT_DATE_SAME_AS_DISBURSEMENT_DATE); + 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("name", GlobalConfigurationConstants.DAILY_TPT_LIMIT); + 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("name", GlobalConfigurationConstants.ENABLE_ADDRESS); + 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("name", GlobalConfigurationConstants.SUB_RATES); + 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("name", GlobalConfigurationConstants.LOAN_RESCHEDULE_IS_FIRST_PAYDAY_ALLOWED_ON_HOLIDAY); + 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("name", GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_PAYMENT_TYPE); + 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("name", GlobalConfigurationConstants.ACCOUNT_MAPPING_FOR_CHARGE); + 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); + GlobalConfigurationConstants.FIXED_DEPOSIT_TRANSFER_INTEREST_NEXT_DAY_FOR_PERIOD_END_POSTING); + 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("name", + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING); + 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); + GlobalConfigurationConstants.ALLOW_BACKDATED_TRANSACTION_BEFORE_INTEREST_POSTING_DATE_FOR_DAYS); + 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("name", GlobalConfigurationConstants.CUSTOM_ACCOUNT_NUMBER_LENGTH); + 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("name", GlobalConfigurationConstants.RANDOM_ACCOUNT_NUMBER); + 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("name", GlobalConfigurationConstants.IS_INTEREST_TO_BE_RECOVERED_FIRST_WHEN_GREATER_THAN_EMI); + 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("name", GlobalConfigurationConstants.IS_PRINCIPAL_COMPOUNDING_DISABLED_FOR_OVERDUE_LOANS); + 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("name", GlobalConfigurationConstants.ENABLE_BUSINESS_DATE); + 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("name", GlobalConfigurationConstants.ENABLE_AUTOMATIC_COB_DATE_ADJUSTMENT); + 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("name", GlobalConfigurationConstants.ENABLE_POST_REVERSAL_TXNS_FOR_REVERSE_TRANSACTIONS); + 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("name", GlobalConfigurationConstants.PURGE_EXTERNAL_EVENTS_OLDER_THAN_DAYS); + 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("name", GlobalConfigurationConstants.DAYS_BEFORE_REPAYMENT_IS_DUE); + 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("name", GlobalConfigurationConstants.DAYS_AFTER_REPAYMENT_IS_OVERDUE); + 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("name", GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID); + 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("name", GlobalConfigurationConstants.PURGE_PROCESSED_COMMANDS_OLDER_THAN_DAYS); + 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("name", GlobalConfigurationConstants.ENABLE_COB_BULK_EVENT); + 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("name", GlobalConfigurationConstants.EXTERNAL_EVENT_BATCH_SIZE); + 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("name", GlobalConfigurationConstants.REPORT_EXPORT_S3_FOLDER_NAME); + 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("name", GlobalConfigurationConstants.LOAN_ARREARS_DELINQUENCY_DISPLAY_DATA); + 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("name", GlobalConfigurationConstants.CHARGE_ACCRUAL_DATE); + 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("name", GlobalConfigurationConstants.ASSET_EXTERNALIZATION_OF_NON_ACTIVE_LOANS); + 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("name", GlobalConfigurationConstants.ENABLE_SAME_MAKER_CHECKER); + 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("name", GlobalConfigurationConstants.NEXT_PAYMENT_DUE_DATE); + 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("name", GlobalConfigurationConstants.ENABLE_PAYMENT_HUB_INTEGRATION); + enablePaymentHubIntegrationConfig.put("value", 0L); enablePaymentHubIntegrationConfig.put("enabled", false); enablePaymentHubIntegrationConfig.put("trapDoor", false); enablePaymentHubIntegrationConfig.put("string_value", "enable payment hub integration"); @@ -602,159 +531,21 @@ public class GlobalConfigurationHelper { 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()); + ok(fineract().legacy.updateGlobalConfiguration(configName, value)); } - // 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; - } - - 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/common/report/ReportHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/report/ReportHelper.java new file mode 100644 index 000000000..af27fd2c2 --- /dev/null +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/report/ReportHelper.java @@ -0,0 +1,32 @@ +/** + * 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.common.report; + +import java.io.IOException; +import java.util.Map; +import okhttp3.ResponseBody; +import org.apache.fineract.integrationtests.client.IntegrationTest; +import retrofit2.Response; + +public class ReportHelper extends IntegrationTest { + + public Response runReport(String reportName, Map reportParameters) throws IOException { + return fineract().reportsRun.runReportGetFile("Transaction Summary Report with Asset Owner", reportParameters, false).execute(); + } +} 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 337c64452..82961ed2c 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,10 +61,12 @@ import org.apache.fineract.client.models.GetDataTablesResponse; 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; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.dataqueries.data.EntityTables; import org.apache.fineract.integrationtests.common.BusinessDateHelper; @@ -106,6 +108,7 @@ public class DatatableAdvancedQueryTest { private DatatableHelper datatableHelper; private SavingsProductHelper savingsProductHelper; private SavingsAccountHelper savingsAccountHelper; + private GlobalConfigurationHelper globalConfigurationHelper; @BeforeEach public void setup() { @@ -116,6 +119,7 @@ public class DatatableAdvancedQueryTest { datatableHelper = new DatatableHelper(requestSpec, responseSpec); savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec); savingsProductHelper = new SavingsProductHelper(); + globalConfigurationHelper = new GlobalConfigurationHelper(); } @Test @@ -126,7 +130,8 @@ public class DatatableAdvancedQueryTest { LocalDate yesterday = today.minus(1, ChronoUnit.DAYS); String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +202,8 @@ public class DatatableAdvancedQueryTest { deleteDatatable(datatable, transactionIdD1, transactionIdD2, transactionIdW1); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @@ -210,7 +216,8 @@ public class DatatableAdvancedQueryTest { LocalDate yesterday = today.minus(1, ChronoUnit.DAYS); String yesterdayS = DateUtils.format(yesterday, SAVINGS_DATE_FORMAT); try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, true); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +305,8 @@ public class DatatableAdvancedQueryTest { deleteDatatable(datatable, transactionIdD1, transactionIdD2, transactionIdW1); } finally { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, false); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 91e820f8e..3de729848 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,20 @@ import org.apache.fineract.client.models.GetDelinquencyTagHistoryResponse; 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.infrastructure.configuration.api.GlobalConfigurationConstants; +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 +64,9 @@ import org.apache.http.HttpStatus; 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 +87,12 @@ public class InlineLoanCOBTest { @Test public void testInlineCOB() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); final Integer clientID = ClientHelper.createClient(requestSpec, responseSpec); @@ -141,14 +142,16 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBCatchUpLoans() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); @@ -236,17 +239,20 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnRepaymentWithSoftLockedLoan() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -295,16 +301,19 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBCatchUpOnRepaymentWithNotLockedLoan() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -352,16 +361,19 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnBatchAPIWithOldRelativeUrls() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -419,16 +431,19 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); } } @Test public void testInlineCOBOnBatchAPI() { try { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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(GlobalConfigurationConstants.PENALTY_WAIT_PERIOD, + new PutGlobalConfigurationsRequest().value(0L)); loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec); loanAccountLockHelper = new LoanAccountLockHelper(requestSpec, new ResponseSpecBuilder().expectStatusCode(202).build()); @@ -486,7 +501,8 @@ public class InlineLoanCOBTest { 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(GlobalConfigurationConstants.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 de22d71bb..16eb0ccf6 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,14 @@ import org.apache.fineract.client.models.PageExternalTransferData; 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.infrastructure.configuration.api.GlobalConfigurationConstants; +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 +69,14 @@ 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.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 +132,7 @@ public class ExternalAssetOwnerTransferCancelTest { @Test public void successCancelSale() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -176,8 +174,7 @@ public class ExternalAssetOwnerTransferCancelTest { @Test public void saleAndBuybackOnTheSameDay() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -276,9 +273,9 @@ public class ExternalAssetOwnerTransferCancelTest { } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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 +284,8 @@ public class ExternalAssetOwnerTransferCancelTest { 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(GlobalConfigurationConstants.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 132f28cb7..ba1a9bea4 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,14 @@ import org.apache.fineract.client.models.ExternalTransferData; 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.infrastructure.configuration.api.GlobalConfigurationConstants; +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 +71,7 @@ import org.junit.jupiter.api.Assertions; 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 +158,10 @@ public class ExternalAssetOwnerTransferTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(true)); + BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, date); } protected void cleanUpAndRestoreBusinessDate() { @@ -168,9 +170,9 @@ public class ExternalAssetOwnerTransferTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 bee35a68a..82d84e15d 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 @@ -64,15 +64,16 @@ 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.PostLoansLoanIdTransactionsRequest; +import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.client.util.CallFailedRuntimeException; +import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.infrastructure.event.external.service.validation.ExternalEventDTO; -import org.apache.fineract.integrationtests.client.IntegrationTest; +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.OfficeHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -85,8 +86,8 @@ import org.apache.fineract.integrationtests.common.externalevents.ExternalEvents 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.report.ReportHelper; import org.hamcrest.Matchers; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; @@ -95,8 +96,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @SuppressWarnings("rawtypes") -@ExtendWith({ LoanTestLifecycleExtension.class, ExternalEventsExtension.class }) -public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { +@ExtendWith({ ExternalEventsExtension.class }) +public class InitiateExternalAssetOwnerTransferTest extends BaseLoanIntegrationTest { private static ResponseSpecification RESPONSE_SPEC; private static RequestSpecification REQUEST_SPEC; @@ -113,6 +114,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { private static OfficeHelper OFFICE_HELPER; private static LocalDate TODAYS_DATE; public String ownerExternalId; + private static ReportHelper reportHelper; private final DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter(); @BeforeAll @@ -141,6 +143,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { OVERPAYMENT_ACCOUNT = accountHelper.createLiabilityAccount(); setProperFinancialActivity(TRANSFER_ACCOUNT); + reportHelper = new ReportHelper(); } private static void setProperFinancialActivity(Account transferAccount) { @@ -154,8 +157,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleActiveLoanToExternalAssetOwnerWithCancelAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); ExternalEventHelper.deleteAllExternalEvents(REQUEST_SPEC, new ResponseSpecBuilder().expectStatusCode(Matchers.is(204)).build()); @@ -354,8 +356,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleActiveLoanToExternalAssetOwnerAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -487,8 +488,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleOverpaidLoanToExternalAssetOwnerAndBuybackADayLater() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -604,8 +604,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleIsNotAllowedWhenTransferIsAlreadyPending() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -623,8 +622,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleIsNotAllowedWhenLoanIsNotActive() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -644,8 +642,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleIsDeclinedWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -668,8 +665,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void buybackIsExecutedWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -700,8 +696,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void buybackAndSaleIsCancelledWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -728,8 +723,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void sameDayBuybackAndSaleIsCancelledWhenLoanIsCancelled() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -756,8 +750,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleAndBuybackOnTheSameDay() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -807,8 +800,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleAndBuybackMultipleTimes() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -842,8 +834,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void buybackExceptionHandling() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); CallFailedRuntimeException exception = assertThrows(CallFailedRuntimeException.class, () -> createBuybackTransfer(1, null)); @@ -893,8 +884,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void saleExceptionHandling() { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); Integer clientID = createClient(); Integer loanID = createLoanForClient(clientID); @@ -943,8 +933,7 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { @Test public void transactionSummaryReportWithAssetOwner() throws IOException { try { - GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, - GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.ENABLE_AUTO_GENERATED_EXTERNAL_ID, true); setInitialBusinessDate("2020-03-02"); ExternalEventHelper.deleteAllExternalEvents(REQUEST_SPEC, new ResponseSpecBuilder().expectStatusCode(Matchers.is(204)).build()); @@ -1029,8 +1018,8 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { getAndValidateThereIsNoActiveMapping(saleTransferResponse.getResourceExternalId()); retrieveResponse = EXTERNAL_ASSET_OWNER_HELPER.retrieveTransfersByLoanId(loanID.longValue()); - final var reportResult = fineract().reportsRun.runReportGetFile("Transaction Summary Report with Asset Owner", - Map.of("R_endDate", "2020-03-03", "R_officeId", officeId.toString(), "output-type", "CSV"), false).execute(); + final var reportResult = reportHelper.runReport("Transaction Summary Report with Asset Owner", + Map.of("R_endDate", "2020-03-03", "R_officeId", officeId.toString(), "output-type", "CSV")); assertNotNull(reportResult.body()); final var csvContent = reportResult.body().string(); @@ -1225,9 +1214,9 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { } private void setInitialBusinessDate(String date) { - GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE); + globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.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() { @@ -1236,9 +1225,9 @@ public class InitiateExternalAssetOwnerTransferTest extends IntegrationTest { 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(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE, + new PutGlobalConfigurationsRequest().enabled(false)); + globalConfigurationHelper.manageConfigurations(GlobalConfigurationConstants.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 13a0c2a40..b8bdb42d6 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,7 @@ import lombok.extern.slf4j.Slf4j; 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.infrastructure.configuration.api.GlobalConfigurationConstants; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.junit.jupiter.api.Test; @@ -47,9 +47,8 @@ public class SearchExternalAssetOwnerTransferTest extends ExternalAssetOwnerTran 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(GlobalConfigurationConstants.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");