FINERACT-2421: Move E2E init data into runner

This commit is contained in:
Adam Saghy
2026-01-16 10:37:26 +01:00
parent ea1609120f
commit 0f73ae1eb7
19 changed files with 12 additions and 13 deletions
@@ -1,50 +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.test.initializer.global;
import static org.apache.fineract.test.initializer.global.GlobalConfigurationGlobalInitializerStep.CONFIG_KEY_ENABLE_BUSINESS_DATE;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.test.helper.BusinessDateHelper;
import org.apache.fineract.test.helper.GlobalConfigurationHelper;
import org.apache.fineract.test.initializer.scenario.FineractScenarioInitializerStep;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
public class BusinessDateInitializerStep implements FineractScenarioInitializerStep {
private final BusinessDateHelper businessDateHelper;
private final GlobalConfigurationHelper configurationHelper;
@Override
public void initializeForScenario() {
configurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
businessDateHelper.setBusinessDateToday();
}
@Override
public void resetAfterScenario() {
configurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
businessDateHelper.setBusinessDateToday();
configurationHelper.disableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
}
}
@@ -1,239 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.ChargeData;
import org.apache.fineract.client.models.ChargeRequest;
import org.apache.fineract.client.models.PostChargesResponse;
import org.apache.fineract.test.data.ChargeCalculationType;
import org.apache.fineract.test.data.ChargePaymentMode;
import org.apache.fineract.test.data.ChargeProductAppliesTo;
import org.apache.fineract.test.data.ChargeTimeType;
import org.apache.fineract.test.data.CurrencyOptions;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
public class ChargeGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String CURRENCY_CODE = CurrencyOptions.EUR.value;
public static final String MONTH_DAY_FORMAT = "dd MMM";
public static final String LOCALE_EN = "en";
public static final Integer CHARGE_PAYMENT_MODE = ChargePaymentMode.REGULAR.value;
public static final Enum<ChargeProductAppliesTo> CHARGE_APPLIES_TO_LOAN = ChargeProductAppliesTo.LOAN;
public static final Enum<ChargeProductAppliesTo> CHARGE_APPLIES_TO_CLIENT = ChargeProductAppliesTo.CLIENT;
public static final String CHARGE_LOAN_PERCENTAGE_LATE_FEE = "% Late fee";
public static final String CHARGE_LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST = "% Late fee amount+interest";
public static final String CHARGE_LOAN_PERCENTAGE_PROCESSING_FEE = "% Processing fee";
public static final String CHARGE_LOAN_FIXED_LATE_FEE = "Fixed Late fee";
public static final String CHARGE_LOAN_FIXED_RETURNED_PAYMENT_FEE = "Fixed Returned payment fee";
public static final String CHARGE_LOAN_SNOOZE_FEE = "Snooze fee";
public static final String CHARGE_LOAN_NSF_FEE = "NSF fee";
public static final String CHARGE_LOAN_DISBURSEMENT_PERCENT_FEE = "Disbursement percentage fee";
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_PERCENT_FEE = "Tranche Disbursement percentage fee";
public static final String CHARGE_LOAN_INSTALLMENT_FEE_FLAT = "Installment flat fee";
public static final String CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT = "Installment percentage amount fee";
public static final String CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_INTEREST = "Installment percentage interest fee";
public static final String CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT_PLUS_INTEREST = "Installment percentage amount + interest fee";
public static final String CHARGE_CLIENT_FIXED_FEE = "Fixed fee for Client";
public static final String CHARGE_DISBURSEMENT_CHARGE = "Disbursement Charge";
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT = "Tranche Disbursement Charge Amount";
public static final String CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT = "Tranche Disbursement Charge Percent";
public static final Double CHARGE_AMOUNT_FLAT = 25D;
public static final Double CHARGE_INSTALLMENT_FEE_AMOUNT_FLAT = 10D;
public static final Double CHARGE_INSTALLMENT_FEE_AMOUNT_PERCENTAGE = 1D;
public static final Double CHARGE_AMOUNT_PERCENTAGE = 5D;
public static final Double CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE = 1.5D;
public static final Double CHARGE_AMOUNT_INSTALLMENT_PERCENTAGE = 1.5D;
public static final Double CHARGE_AMOUNT_OVERDUE_PERCENTAGE = 1.5D;
public static final Integer CHARGE_TIME_TYPE_OVERDUE_FEES = ChargeTimeType.OVERDUE_FEES.value;
public static final Integer CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE = ChargeTimeType.SPECIFIED_DUE_DATE.value;
public static final Integer CHARGE_TIME_TYPE_DISBURSEMENT = ChargeTimeType.DISBURSEMENT.value;
public static final Integer CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT = ChargeTimeType.TRANCHE_DISBURSEMENT.value;
public static final Integer CHARGE_TIME_TYPE_INSTALLMENT = ChargeTimeType.INSTALLMENT_FEE.value;
public static final Integer CHARGE_CALCULATION_TYPE_FLAT = ChargeCalculationType.FLAT.value;
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT = ChargeCalculationType.PERCENTAGE_AMOUNT.value;
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST = ChargeCalculationType.PERCENTAGE_INTEREST.value;
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT = ChargeCalculationType.PERCENTAGE_DISBURSEMENT_AMOUNT.value;
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST = ChargeCalculationType.PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST.value;
private final FineractFeignClient fineractClient;
@Override
public void initialize() throws Exception {
List<ChargeData> existingCharges = new ArrayList<>();
try {
existingCharges = fineractClient.charges().retrieveAllCharges(Map.of());
} catch (Exception e) {
log.debug("Could not retrieve existing charges, will create them", e);
}
final List<ChargeData> charges = existingCharges;
PostChargesResponse responseLoanPercentLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_PERCENTAGE_LATE_FEE, CHARGE_TIME_TYPE_OVERDUE_FEES, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
CHARGE_AMOUNT_OVERDUE_PERCENTAGE, true, true);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_LATE_CREATE_RESPONSE, responseLoanPercentLate);
PostChargesResponse responseLoanPercentProcessing = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_PERCENTAGE_PROCESSING_FEE, CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE,
CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_AMOUNT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_PROCESSING_CREATE_RESPONSE, responseLoanPercentProcessing);
PostChargesResponse responseLoanFixedLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_FIXED_LATE_FEE,
CHARGE_TIME_TYPE_OVERDUE_FEES, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, true);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_FIXED_LATE_CREATE_RESPONSE, responseLoanFixedLate);
PostChargesResponse responseLoanFixedReturnedPayment = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_FIXED_RETURNED_PAYMENT_FEE, CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT,
CHARGE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_FIXED_RETURNED_PAYMENT_CREATE_RESPONSE, responseLoanFixedReturnedPayment);
PostChargesResponse responseLoanSnooze = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_SNOOZE_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_SNOOZE_FEE_CREATE_RESPONSE, responseLoanSnooze);
PostChargesResponse responseLoanNsf = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN, CHARGE_LOAN_NSF_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, true);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_NSF_FEE_CREATE_RESPONSE, responseLoanNsf);
PostChargesResponse responseLoanDisbursePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_DISBURSEMENT_PERCENT_FEE, CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENET_FEE_CREATE_RESPONSE, responseLoanDisbursePercent);
PostChargesResponse responseLoanTrancheDisbursePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_PERCENT_FEE, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, CHARGE_AMOUNT_DISBURSEMENT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_PERCENT_CREATE_RESPONSE,
responseLoanTrancheDisbursePercent);
PostChargesResponse responseLoanInstallmentPercentAmountPlusInterest = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT_PLUS_INTEREST, CHARGE_TIME_TYPE_INSTALLMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_INSTALLMENT_FEE_AMOUNT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_AMOUNT_PLUS_INTEREST_CREATE_RESPONSE,
responseLoanInstallmentPercentAmountPlusInterest);
PostChargesResponse responseLoanPercentAmountPlusInterestLate = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_PERCENTAGE_LATE_FEE_AMOUNT_PLUS_INTEREST, CHARGE_TIME_TYPE_OVERDUE_FEES,
CHARGE_CALCULATION_TYPE_PERCENTAGE_LOAN_AMOUNT_PLUS_INTEREST, CHARGE_AMOUNT_OVERDUE_PERCENTAGE, true, true);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_PERCENT_LATE_AMOUNT_PLUS_INTEREST_CREATE_RESPONSE,
responseLoanPercentAmountPlusInterestLate);
PostChargesResponse responseClientFixed = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_CLIENT, CHARGE_CLIENT_FIXED_FEE,
CHARGE_TIME_TYPE_SPECIFIED_DUE_DATE, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_CLIENT_FIXED_FEE_CREATE_RESPONSE, responseClientFixed);
PostChargesResponse responseDisbursementCharge = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_DISBURSEMENT_CHARGE, CHARGE_TIME_TYPE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, CHARGE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_DISBURSEMENT_CHARGE_CREATE_RESPONSE, responseDisbursementCharge);
PostChargesResponse responseTrancheDisbursementCharge = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_AMOUNT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT, CHARGE_CALCULATION_TYPE_FLAT, 10.0,
true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_FLAT_CREATE_RESPONSE,
responseTrancheDisbursementCharge);
PostChargesResponse responseTrancheDisbursementChargePercent = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT, CHARGE_TIME_TYPE_TRANCHE_DISBURSEMENT,
CHARGE_CALCULATION_TYPE_PERCENTAGE_DISBURSEMENT_AMOUNT, 2.0, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_TRANCHE_DISBURSEMENT_CHARGE_PERCENT_CREATE_RESPONSE,
responseTrancheDisbursementChargePercent);
PostChargesResponse responseLoanInstallmentFlat = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_FLAT, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_FLAT,
CHARGE_INSTALLMENT_FEE_AMOUNT_FLAT, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_FLAT_CREATE_RESPONSE, responseLoanInstallmentFlat);
PostChargesResponse responseLoanInstallmentPercentAmount = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_AMOUNT, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT,
CHARGE_INSTALLMENT_FEE_AMOUNT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_AMOUNT_CREATE_RESPONSE,
responseLoanInstallmentPercentAmount);
PostChargesResponse responseLoanInstallmentPercentInterest = createChargeIfNotExists(charges, CHARGE_APPLIES_TO_LOAN,
CHARGE_LOAN_INSTALLMENT_FEE_PERCENT_INTEREST, CHARGE_TIME_TYPE_INSTALLMENT, CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST,
CHARGE_AMOUNT_PERCENTAGE, true, false);
TestContext.INSTANCE.set(TestContextKey.CHARGE_FOR_LOAN_INSTALLMENT_FEE_PERCENTAGE_INTEREST_CREATE_RESPONSE,
responseLoanInstallmentPercentInterest);
}
private PostChargesResponse createChargeIfNotExists(List<ChargeData> existingCharges, Enum<ChargeProductAppliesTo> appliesTo,
String name, Integer chargeTimeType, Integer chargeCalculationType, Double amount, Boolean isActive, Boolean isPenalty)
throws Exception {
ChargeRequest request = defaultChargesRequest(appliesTo, name, chargeTimeType, chargeCalculationType, amount, isActive, isPenalty);
try {
return ok(() -> fineractClient.charges().createCharge(request, Map.of()));
} catch (CallFailedRuntimeException e) {
if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
log.debug("Charge '{}' already exists, retrieving existing charge", name);
ChargeData existing = existingCharges.stream().filter(c -> name.equals(c.getName())).findFirst().orElse(null);
if (existing != null) {
PostChargesResponse response = new PostChargesResponse();
response.setResourceId(existing.getId());
return response;
}
}
throw e;
}
}
public static ChargeRequest defaultChargesRequest(Enum<ChargeProductAppliesTo> appliesTo, String name, Integer chargeTimeType,
Integer chargeCalculationType, Double amount, Boolean isActive, Boolean isPenalty) throws Exception {
ChargeRequest request = new ChargeRequest();
Integer chargeAppliesTo;
if (appliesTo.equals(ChargeProductAppliesTo.CLIENT)) {
chargeAppliesTo = ChargeProductAppliesTo.CLIENT.value;
} else if (appliesTo.equals(ChargeProductAppliesTo.LOAN)) {
chargeAppliesTo = ChargeProductAppliesTo.LOAN.value;
request.chargePaymentMode(CHARGE_PAYMENT_MODE);
} else {
throw new Exception(ErrorMessageHelper.chargeAppliesToIsInvalid(appliesTo));
}
request//
.chargeAppliesTo(chargeAppliesTo)//
.name(name)//
.currencyCode(CURRENCY_CODE)//
.chargeTimeType(chargeTimeType)//
.chargeCalculationType(chargeCalculationType)//
.amount(amount)//
.active(isActive)//
.penalty(isPenalty)//
.monthDayFormat(MONTH_DAY_FORMAT)//
.locale(LOCALE_EN);//
return request;
}
}
@@ -1,35 +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.test.initializer.global;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.test.helper.WorkFlowJobHelper;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@Component
public class CobBusinessStepInitializerStep implements FineractGlobalInitializerStep {
private final WorkFlowJobHelper workFlowJobHelper;
@Override
public void initialize() {
workFlowJobHelper.setWorkflowJobs();
}
}
@@ -1,318 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.PostCodeValuesDataRequest;
import org.apache.fineract.client.models.PostCodesRequest;
import org.apache.fineract.client.models.PutCodeValuesDataRequest;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class CodeGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String CODE_NAME_FINANCIAL_INSTRUMENT = "financial_instrument";
public static final String CODE_NAME_TRANSACTION_TYPE = "transaction_type";
public static final String CODE_NAME_BANKRUPTCY_TAG = "bankruptcy_tag";
public static final String CODE_NAME_PENDING_FRAUD_TAG = "pending_fraud_tag";
public static final String CODE_NAME_PENDING_DECEASED_TAG = "pending_deceased_tag";
public static final String CODE_NAME_HARDSHIP_TAG = "hardship_tag";
public static final String CODE_NAME_ACTIVE_DUTY_TAG = "active_duty_tag";
public static final Long CODE_VALUE_ADDRESS_TYPE_ID = 29L;
public static final String CODE_VALUE_ADDRESS_TYPE_RESIDENTIAL = "Residential address";
public static final String CODE_VALUE_ADDRESS_TYPE_OFFICE = "Office address";
public static final Long CODE_VALUE_COUNTRY_ID = 28L;
public static final String CODE_VALUE_COUNTRY_GERMANY = "Germany";
public static final Long CODE_VALUE_STATE_ID = 27L;
public static final String CODE_VALUE_STATE_BERLIN = "Berlin";
public static final Long CODE_VALUE_FINANCIAL_INSTRUMENT_ID = 39L;
public static final String CODE_VALUE_FINANCIAL_INSTRUMENT_DEBIT = "debit_card";
public static final String CODE_VALUE_FINANCIAL_INSTRUMENT_CREDIT = "credit_card";
public static final String CODE_VALUE_FINANCIAL_INSTRUMENT_FRAUD = "Fraud";
public static final String CODE_VALUE_FINANCIAL_INSTRUMENT_DELINQUENT = "Delinquent";
public static final String CODE_VALUE_FINANCIAL_INSTRUMENT_OTHER = "Other";
public static final Long CODE_VALUE_TRANSACTION_TYPE_ID = 40L;
public static final String CODE_VALUE_TRANSACTION_TYPE_SCHEDULED_PAYMENT = "scheduled_payment";
public static final Long CODE_VALUE_BANKRUPTCY_TAG_ID = 41L;
public static final String CODE_VALUE_BANKRUPTCY_TAG_PENDING = "pending_bankruptcy";
public static final String CODE_VALUE_BANKRUPTCY_TAG_BANKRUPTCY = "bankruptcy";
public static final Long CODE_VALUE_PENDING_FRAUD_TAG_ID = 42L;
public static final String CODE_VALUE_PENDING_FRAUD_TAG_PENDING = "pending_fraud";
public static final String CODE_VALUE_PENDING_FRAUD_TAG_FRAUD = "fraud";
public static final Long CODE_VALUE_PENDING_DECEASED_TAG_ID = 43L;
public static final String CODE_VALUE_PENDING_DECEASED_TAG_PENDING = "pending_deceased";
public static final String CODE_VALUE_PENDING_DECEASED_TAG_DECEASED = "deceased";
public static final Long CODE_VALUE_HARDSHIP_TAG_ID = 44L;
public static final String CODE_VALUE_HARDSHIP_TAG_ACTIVE = "active";
public static final String CODE_VALUE_HARDSHIP_TAG_INACTIVE = "inactive";
public static final Long CODE_VALUE_ACTIVE_DUTY_TAG_ID = 45L;
public static final String CODE_VALUE_ACTIVE_DUTY_TAG_ACTIVE = "active";
public static final String CODE_VALUE_ACTIVE_DUTY_TAG_INACTIVE = "inactive";
public static final Long CODE_VALUE_CUSTOMER_IDENTIFIERS_ID = 1L;
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_1 = "Passport";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_2 = "Id";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_3 = "Drivers License";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_4 = "Any Other Id Type";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_5 = "SSN";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_6 = "TIN";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_7 = "ITIN";
public static final String CODE_VALUE_CUSTOMER_IDENTIFIERS_8 = "EIN";
public static final Long CODE_VALUE_GENDER_ID = 4L;
public static final String CODE_VALUE_GENDER_FEMALE = "Female";
public static final String CODE_VALUE_GENDER_MALE = "Male";
public static final Long CODE_VALUE_CLIENT_TYPE_ID = 16L;
public static final String CODE_VALUE_CLIENT_TYPE_CORPORATE = "Corporate";
public static final String CODE_VALUE_CLIENT_TYPE_LEGAL = "Legal";
public static final String CODE_VALUE_CLIENT_TYPE_NON_LEGAL = "Non-legal";
public static final Long CODE_VALUE_CLIENT_CLASSIFICATION_ID = 17L;
public static final String CODE_VALUE_CLIENT_CLASSIFICATION_LAWYER = "Lawyer";
public static final String CODE_VALUE_CLIENT_CLASSIFICATION_DIRECTOR = "Director";
public static final String CODE_VALUE_CLIENT_CLASSIFICATION_NONE = "None";
public static final Long CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_ID = 31L;
public static final String CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_SPOUSE = "Spouse";
public static final String CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_FATHER = "Father";
public static final String CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_MOTHER = "Mother";
public static final String CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_CHILD = "Child";
public static final Long CODE_VALUE_FAMILY_MEMBER_PROFESSION_ID = 32L;
public static final String CODE_VALUE_FAMILY_MEMBER_PROFESSION_EMPLOYEE = "Employee";
public static final String CODE_VALUE_FAMILY_MEMBER_PROFESSION_SELF_EMPLOYED = "Self-Employed";
public static final Long CODE_VALUE_FAMILY_MARITAL_STATUS_ID = 30L;
public static final String CODE_VALUE_FAMILY_MARITAL_STATUS_MARRIED = "Married";
public static final String CODE_VALUE_FAMILY_MARITAL_STATUS_SINGLE = "Single";
public static final String CODE_VALUE_FAMILY_MARITAL_STATUS_WIDOWED = "Widowed";
public static final Long CODE_VALUE_CONSTITUTION_ID = 24L;
public static final String CODE_VALUE_CONSTITUTION_TEST = "Test";
public static final Long CODE_VALUE_RESCHEDULE_REASON_ID = 23L;
public static final String CODE_VALUE_RESCHEDULE_REASON_TEST = "Test";
public static final Long CODE_VALUE_WRITE_OFF_REASON_ID = 26L;
public static final String CODE_VALUE_WRITE_OFF_REASON_TEST_1 = "Bad Debt";
public static final String CODE_VALUE_WRITE_OFF_REASON_TEST_2 = "Forgiven";
public static final String CODE_VALUE_WRITE_OFF_REASON_TEST_3 = "Test";
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
createCodeNames();
createCodeValues();
}
private void createCodeValues() {
// address type
List<String> addressNames = new ArrayList<>();
addressNames.add(CODE_VALUE_ADDRESS_TYPE_RESIDENTIAL);
addressNames.add(CODE_VALUE_ADDRESS_TYPE_OFFICE);
createCodeValues(CODE_VALUE_ADDRESS_TYPE_ID, addressNames);
// Country
List<String> countryNames = new ArrayList<>();
countryNames.add(CODE_VALUE_COUNTRY_GERMANY);
createCodeValues(CODE_VALUE_COUNTRY_ID, countryNames);
// State
List<String> stateNames = new ArrayList<>();
stateNames.add(CODE_VALUE_STATE_BERLIN);
createCodeValues(CODE_VALUE_STATE_ID, stateNames);
// financial instrument
List<String> financialInstrumentNames = new ArrayList<>();
financialInstrumentNames.add(CODE_VALUE_FINANCIAL_INSTRUMENT_DEBIT);
financialInstrumentNames.add(CODE_VALUE_FINANCIAL_INSTRUMENT_CREDIT);
financialInstrumentNames.add(CODE_VALUE_FINANCIAL_INSTRUMENT_FRAUD);
financialInstrumentNames.add(CODE_VALUE_FINANCIAL_INSTRUMENT_DELINQUENT);
financialInstrumentNames.add(CODE_VALUE_FINANCIAL_INSTRUMENT_OTHER);
createCodeValues(CODE_VALUE_FINANCIAL_INSTRUMENT_ID, financialInstrumentNames);
// transaction type
List<String> transactionTypeNames = new ArrayList<>();
transactionTypeNames.add(CODE_VALUE_TRANSACTION_TYPE_SCHEDULED_PAYMENT);
createCodeValues(CODE_VALUE_TRANSACTION_TYPE_ID, transactionTypeNames);
// bankruptcy tag
List<String> bankruptcyTagNames = new ArrayList<>();
bankruptcyTagNames.add(CODE_VALUE_BANKRUPTCY_TAG_PENDING);
bankruptcyTagNames.add(CODE_VALUE_BANKRUPTCY_TAG_BANKRUPTCY);
createCodeValues(CODE_VALUE_BANKRUPTCY_TAG_ID, bankruptcyTagNames);
// pending fraud tag
List<String> pendingFraudTagNames = new ArrayList<>();
pendingFraudTagNames.add(CODE_VALUE_PENDING_FRAUD_TAG_PENDING);
pendingFraudTagNames.add(CODE_VALUE_PENDING_FRAUD_TAG_FRAUD);
createCodeValues(CODE_VALUE_PENDING_FRAUD_TAG_ID, pendingFraudTagNames);
// pending deceased tag
List<String> pendingDeceasedTagNames = new ArrayList<>();
pendingDeceasedTagNames.add(CODE_VALUE_PENDING_DECEASED_TAG_PENDING);
pendingDeceasedTagNames.add(CODE_VALUE_PENDING_DECEASED_TAG_DECEASED);
createCodeValues(CODE_VALUE_PENDING_DECEASED_TAG_ID, pendingDeceasedTagNames);
// hardship tag
List<String> hardshipTagNames = new ArrayList<>();
hardshipTagNames.add(CODE_VALUE_HARDSHIP_TAG_ACTIVE);
hardshipTagNames.add(CODE_VALUE_HARDSHIP_TAG_INACTIVE);
createCodeValues(CODE_VALUE_HARDSHIP_TAG_ID, hardshipTagNames);
// active duty tag
List<String> activeDutyTagNames = new ArrayList<>();
activeDutyTagNames.add(CODE_VALUE_ACTIVE_DUTY_TAG_ACTIVE);
activeDutyTagNames.add(CODE_VALUE_ACTIVE_DUTY_TAG_INACTIVE);
createCodeValues(CODE_VALUE_ACTIVE_DUTY_TAG_ID, activeDutyTagNames);
// customer identifiers put/post
List<String> customerIdentifierNamesPut = new ArrayList<>();
customerIdentifierNamesPut.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_1);
customerIdentifierNamesPut.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_2);
customerIdentifierNamesPut.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_3);
customerIdentifierNamesPut.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_4);
updateCodeValues(CODE_VALUE_CUSTOMER_IDENTIFIERS_ID, customerIdentifierNamesPut);
List<String> customerIdentifierNamesPost = new ArrayList<>();
customerIdentifierNamesPost.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_5);
customerIdentifierNamesPost.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_6);
customerIdentifierNamesPost.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_7);
customerIdentifierNamesPost.add(CODE_VALUE_CUSTOMER_IDENTIFIERS_8);
createCodeValues(CODE_VALUE_CUSTOMER_IDENTIFIERS_ID, customerIdentifierNamesPost);
// gender
List<String> genderNames = new ArrayList<>();
genderNames.add(CODE_VALUE_GENDER_FEMALE);
genderNames.add(CODE_VALUE_GENDER_MALE);
createCodeValues(CODE_VALUE_GENDER_ID, genderNames);
// client type
List<String> clientTypeNames = new ArrayList<>();
clientTypeNames.add(CODE_VALUE_CLIENT_TYPE_CORPORATE);
clientTypeNames.add(CODE_VALUE_CLIENT_TYPE_LEGAL);
clientTypeNames.add(CODE_VALUE_CLIENT_TYPE_NON_LEGAL);
createCodeValues(CODE_VALUE_CLIENT_TYPE_ID, clientTypeNames);
// client classification
List<String> clientClassificationNames = new ArrayList<>();
clientClassificationNames.add(CODE_VALUE_CLIENT_CLASSIFICATION_LAWYER);
clientClassificationNames.add(CODE_VALUE_CLIENT_CLASSIFICATION_DIRECTOR);
clientClassificationNames.add(CODE_VALUE_CLIENT_CLASSIFICATION_NONE);
createCodeValues(CODE_VALUE_CLIENT_CLASSIFICATION_ID, clientClassificationNames);
// add family member - relationship
List<String> familyMemberRelationshipNames = new ArrayList<>();
familyMemberRelationshipNames.add(CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_SPOUSE);
familyMemberRelationshipNames.add(CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_FATHER);
familyMemberRelationshipNames.add(CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_MOTHER);
familyMemberRelationshipNames.add(CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_CHILD);
createCodeValues(CODE_VALUE_FAMILY_MEMBER_RELATIONSHIP_ID, familyMemberRelationshipNames);
// add family member - profession
List<String> familyMemberProfessionNames = new ArrayList<>();
familyMemberProfessionNames.add(CODE_VALUE_FAMILY_MEMBER_PROFESSION_EMPLOYEE);
familyMemberProfessionNames.add(CODE_VALUE_FAMILY_MEMBER_PROFESSION_SELF_EMPLOYED);
createCodeValues(CODE_VALUE_FAMILY_MEMBER_PROFESSION_ID, familyMemberProfessionNames);
// add family member - marital status
List<String> familyMemberMaritalStatusNames = new ArrayList<>();
familyMemberMaritalStatusNames.add(CODE_VALUE_FAMILY_MARITAL_STATUS_MARRIED);
familyMemberMaritalStatusNames.add(CODE_VALUE_FAMILY_MARITAL_STATUS_SINGLE);
familyMemberMaritalStatusNames.add(CODE_VALUE_FAMILY_MARITAL_STATUS_WIDOWED);
createCodeValues(CODE_VALUE_FAMILY_MARITAL_STATUS_ID, familyMemberMaritalStatusNames);
// add constitution (for client creation as Entity)
List<String> constitutionNames = new ArrayList<>();
constitutionNames.add(CODE_VALUE_CONSTITUTION_TEST);
createCodeValues(CODE_VALUE_CONSTITUTION_ID, constitutionNames);
// add LoanRescheduleReason
List<String> rescheduleReasonNames = new ArrayList<>();
rescheduleReasonNames.add(CODE_VALUE_RESCHEDULE_REASON_TEST);
createCodeValues(CODE_VALUE_RESCHEDULE_REASON_ID, rescheduleReasonNames);
// add Write-off reasons
List<String> writeOffReasonNames = new ArrayList<>();
writeOffReasonNames.add(CODE_VALUE_WRITE_OFF_REASON_TEST_1);
writeOffReasonNames.add(CODE_VALUE_WRITE_OFF_REASON_TEST_2);
writeOffReasonNames.add(CODE_VALUE_WRITE_OFF_REASON_TEST_3);
createCodeValues(CODE_VALUE_WRITE_OFF_REASON_ID, writeOffReasonNames);
}
public void createCodeValues(Long codeId, List<String> codeValueNames) {
codeValueNames.forEach(name -> {
Integer position = codeValueNames.indexOf(name);
PostCodeValuesDataRequest postCodeValuesDataRequest = new PostCodeValuesDataRequest();
postCodeValuesDataRequest.isActive(true);
postCodeValuesDataRequest.name(name);
postCodeValuesDataRequest.position(position);
try {
executeVoid(() -> fineractClient.codeValues().createCodeValue(codeId, postCodeValuesDataRequest, Map.of()));
log.debug("Code value '{}' created successfully", name);
} catch (CallFailedRuntimeException e) {
if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
log.debug("Code value '{}' already exists, skipping creation", name);
return;
}
throw e;
}
});
}
public void updateCodeValues(Long codeId, List<String> codeValueNames) {
codeValueNames.forEach(name -> {
int position = codeValueNames.indexOf(name) + 1;
PutCodeValuesDataRequest putCodeValuesDataRequest = new PutCodeValuesDataRequest();
putCodeValuesDataRequest.isActive(false);
putCodeValuesDataRequest.name(name);
putCodeValuesDataRequest.position(position);
executeVoid(() -> fineractClient.codeValues().updateCodeValue(codeId, (long) position, putCodeValuesDataRequest, Map.of()));
});
}
private void createCodeNames() {
List<String> codesNameList = new ArrayList<>();
codesNameList.add(CODE_NAME_FINANCIAL_INSTRUMENT);
codesNameList.add(CODE_NAME_TRANSACTION_TYPE);
codesNameList.add(CODE_NAME_BANKRUPTCY_TAG);
codesNameList.add(CODE_NAME_PENDING_FRAUD_TAG);
codesNameList.add(CODE_NAME_PENDING_DECEASED_TAG);
codesNameList.add(CODE_NAME_HARDSHIP_TAG);
codesNameList.add(CODE_NAME_ACTIVE_DUTY_TAG);
codesNameList.forEach(codeName -> {
try {
fineractClient.codes().retrieveCodeByName(codeName);
// Code already exists, skip creation
} catch (Exception e) {
// Code doesn't exist, create it
PostCodesRequest postCodesRequest = new PostCodesRequest();
executeVoid(() -> fineractClient.codes().createCode(postCodesRequest.name(codeName), Map.of()));
}
});
}
}
@@ -1,50 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.CurrencyUpdateRequest;
import org.apache.fineract.test.support.TestContext;
import org.apache.fineract.test.support.TestContextKey;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class CurrencyGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final List<String> CURRENCIES = Arrays.asList("EUR", "USD");
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
var request = new CurrencyUpdateRequest();
var response = ok(() -> fineractClient.currency().updateCurrencies(request.currencies(CURRENCIES), Map.of()));
TestContext.INSTANCE.set(TestContextKey.PUT_CURRENCIES_RESPONSE, response);
}
}
@@ -1,201 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.PostColumnHeaderData;
import org.apache.fineract.client.models.PostDataTablesRequest;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class DatatablesGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String DATA_TABLE_1_NAME = "dt_autopay_details";
public static final String DATA_TABLE_1_APP_NAME = "m_loan";
public static final String DATA_TABLE_1_COLUMN_1_NAME = "financial_instruments";
public static final String DATA_TABLE_1_COLUMN_1_TYPE = "Dropdown";
public static final String DATA_TABLE_1_COLUMN_1_CODE = "financial_instrument";
public static final String DATA_TABLE_1_COLUMN_2_NAME = "date_of_payment";
public static final String DATA_TABLE_1_COLUMN_2_TYPE = "Date";
public static final String DATA_TABLE_2_NAME = "dt_schedule_payments";
public static final String DATA_TABLE_2_APP_NAME = "m_loan";
public static final String DATA_TABLE_2_COLUMN_1_NAME = "external_reference_id";
public static final String DATA_TABLE_2_COLUMN_1_TYPE = "String";
public static final Long DATA_TABLE_2_COLUMN_1_LENGTH = 50L;
public static final String DATA_TABLE_2_COLUMN_2_NAME = "scheduled_date";
public static final String DATA_TABLE_2_COLUMN_2_TYPE = "Date";
public static final String DATA_TABLE_2_COLUMN_3_NAME = "amount";
public static final String DATA_TABLE_2_COLUMN_3_TYPE = "Decimal";
public static final String DATA_TABLE_2_COLUMN_4_NAME = "transaction_type";
public static final String DATA_TABLE_2_COLUMN_4_TYPE = "Dropdown";
public static final String DATA_TABLE_2_COLUMN_4_CODE = "transaction_type";
public static final String DATA_TABLE_3_NAME = "dt_user_tags";
public static final String DATA_TABLE_3_APP_NAME = "m_client";
public static final String DATA_TABLE_3_ENTITY_SUBTYPE = "PERSON";
public static final String DATA_TABLE_3_COLUMN_1_NAME = "bankruptcy_tag";
public static final String DATA_TABLE_3_COLUMN_1_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_1_CODE = "bankruptcy_tag";
public static final String DATA_TABLE_3_COLUMN_2_NAME = "pending_fraud_tag";
public static final String DATA_TABLE_3_COLUMN_2_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_2_CODE = "pending_fraud_tag";
public static final String DATA_TABLE_3_COLUMN_3_NAME = "pending_deceased_tag";
public static final String DATA_TABLE_3_COLUMN_3_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_3_CODE = "pending_deceased_tag";
public static final String DATA_TABLE_3_COLUMN_4_NAME = "hardship_tag";
public static final String DATA_TABLE_3_COLUMN_4_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_4_CODE = "hardship_tag";
public static final String DATA_TABLE_3_COLUMN_5_NAME = "active_duty_tag";
public static final String DATA_TABLE_3_COLUMN_5_TYPE = "Dropdown";
public static final String DATA_TABLE_3_COLUMN_5_CODE = "active_duty_tag";
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
// autopay
PostColumnHeaderData column1 = new PostColumnHeaderData();
column1.name(DATA_TABLE_1_COLUMN_1_NAME);
column1.type(DATA_TABLE_1_COLUMN_1_TYPE);
column1.code(DATA_TABLE_1_COLUMN_1_CODE);
column1.mandatory(false);
PostColumnHeaderData column2 = new PostColumnHeaderData();
column2.name(DATA_TABLE_1_COLUMN_2_NAME);
column2.type(DATA_TABLE_1_COLUMN_2_TYPE);
column2.mandatory(false);
List<PostColumnHeaderData> columns = new ArrayList<>();
columns.add(column1);
columns.add(column2);
PostDataTablesRequest postDataTablesRequest = new PostDataTablesRequest();
postDataTablesRequest.datatableName(DATA_TABLE_1_NAME);
postDataTablesRequest.apptableName(DATA_TABLE_1_APP_NAME);
postDataTablesRequest.multiRow(true);
postDataTablesRequest.columns(columns);
createDatatableIdempotent(postDataTablesRequest);
// scheduled payments
PostColumnHeaderData columnScheduled1 = new PostColumnHeaderData();
columnScheduled1.name(DATA_TABLE_2_COLUMN_1_NAME);
columnScheduled1.type(DATA_TABLE_2_COLUMN_1_TYPE);
columnScheduled1.length(DATA_TABLE_2_COLUMN_1_LENGTH);
columnScheduled1.mandatory(false);
PostColumnHeaderData columnScheduled2 = new PostColumnHeaderData();
columnScheduled2.name(DATA_TABLE_2_COLUMN_2_NAME);
columnScheduled2.type(DATA_TABLE_2_COLUMN_2_TYPE);
columnScheduled2.mandatory(false);
PostColumnHeaderData columnScheduled3 = new PostColumnHeaderData();
columnScheduled3.name(DATA_TABLE_2_COLUMN_3_NAME);
columnScheduled3.type(DATA_TABLE_2_COLUMN_3_TYPE);
columnScheduled3.mandatory(false);
PostColumnHeaderData columnScheduled4 = new PostColumnHeaderData();
columnScheduled4.name(DATA_TABLE_2_COLUMN_4_NAME);
columnScheduled4.type(DATA_TABLE_2_COLUMN_4_TYPE);
columnScheduled4.code(DATA_TABLE_2_COLUMN_4_CODE);
columnScheduled4.mandatory(false);
List<PostColumnHeaderData> columnsScheduled = new ArrayList<>();
columnsScheduled.add(columnScheduled1);
columnsScheduled.add(columnScheduled2);
columnsScheduled.add(columnScheduled3);
columnsScheduled.add(columnScheduled4);
PostDataTablesRequest postDataTablesRequestScheduled = new PostDataTablesRequest();
postDataTablesRequestScheduled.datatableName(DATA_TABLE_2_NAME);
postDataTablesRequestScheduled.apptableName(DATA_TABLE_2_APP_NAME);
postDataTablesRequestScheduled.multiRow(true);
postDataTablesRequestScheduled.columns(columnsScheduled);
createDatatableIdempotent(postDataTablesRequestScheduled);
// 3 tags
PostColumnHeaderData column3Tags1 = new PostColumnHeaderData();
column3Tags1.name(DATA_TABLE_3_COLUMN_1_NAME);
column3Tags1.type(DATA_TABLE_3_COLUMN_1_TYPE);
column3Tags1.code(DATA_TABLE_3_COLUMN_1_CODE);
column3Tags1.mandatory(false);
PostColumnHeaderData column3Tags2 = new PostColumnHeaderData();
column3Tags2.name(DATA_TABLE_3_COLUMN_2_NAME);
column3Tags2.type(DATA_TABLE_3_COLUMN_2_TYPE);
column3Tags2.code(DATA_TABLE_3_COLUMN_2_CODE);
column3Tags2.mandatory(false);
PostColumnHeaderData column3Tags3 = new PostColumnHeaderData();
column3Tags3.name(DATA_TABLE_3_COLUMN_3_NAME);
column3Tags3.type(DATA_TABLE_3_COLUMN_3_TYPE);
column3Tags3.code(DATA_TABLE_3_COLUMN_3_CODE);
column3Tags3.mandatory(false);
PostColumnHeaderData column3Tags4 = new PostColumnHeaderData();
column3Tags4.name(DATA_TABLE_3_COLUMN_4_NAME);
column3Tags4.type(DATA_TABLE_3_COLUMN_4_TYPE);
column3Tags4.code(DATA_TABLE_3_COLUMN_4_CODE);
column3Tags4.mandatory(false);
PostColumnHeaderData column3Tags5 = new PostColumnHeaderData();
column3Tags5.name(DATA_TABLE_3_COLUMN_5_NAME);
column3Tags5.type(DATA_TABLE_3_COLUMN_5_TYPE);
column3Tags5.code(DATA_TABLE_3_COLUMN_5_CODE);
column3Tags5.mandatory(false);
List<PostColumnHeaderData> columns3Tags = new ArrayList<>();
columns3Tags.add(column3Tags1);
columns3Tags.add(column3Tags2);
columns3Tags.add(column3Tags3);
columns3Tags.add(column3Tags4);
columns3Tags.add(column3Tags5);
PostDataTablesRequest postDataTablesRequest3Tags = new PostDataTablesRequest();
postDataTablesRequest3Tags.datatableName(DATA_TABLE_3_NAME);
postDataTablesRequest3Tags.apptableName(DATA_TABLE_3_APP_NAME);
postDataTablesRequest3Tags.entitySubType(DATA_TABLE_3_ENTITY_SUBTYPE);
postDataTablesRequest3Tags.multiRow(false);
postDataTablesRequest3Tags.columns(columns3Tags);
createDatatableIdempotent(postDataTablesRequest3Tags);
}
private void createDatatableIdempotent(PostDataTablesRequest datatableRequest) {
String datatableName = datatableRequest.getDatatableName();
try {
fineractClient.dataTables().getDatatable(datatableName, Map.of());
} catch (Exception e) {
log.debug("Datatable '{}' does not exist yet, will create it", datatableName);
executeVoid(() -> fineractClient.dataTables().createDatatable(datatableRequest, Map.of()));
}
}
}
@@ -1,136 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.DelinquencyBucketData;
import org.apache.fineract.client.models.DelinquencyBucketRequest;
import org.apache.fineract.client.models.DelinquencyRangeData;
import org.apache.fineract.client.models.DelinquencyRangeRequest;
import org.apache.fineract.client.models.PostDelinquencyRangeResponse;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class DelinquencyGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String DEFAULT_LOCALE = "en";
public static final List<Integer> DEFAULT_DELINQUENCY_RANGES = Arrays.asList(1, 3, 30, 60, 90, 120, 150, 180, 240);
public static final String DEFAULT_DELINQUENCY_BUCKET_NAME = "Default delinquency bucket";
private final FineractFeignClient fineractClient;
private final List<Long> createdRangeIds = new ArrayList<>();
@Override
public void initialize() {
setDefaultDelinquencyRanges();
setDefaultDelinquencyBucket();
}
public void setDefaultDelinquencyRanges() {
List<DelinquencyRangeData> existingRanges;
try {
existingRanges = fineractClient.delinquencyRangeAndBucketsManagement().getDelinquencyRanges(Map.of());
} catch (Exception e) {
log.debug("Could not retrieve existing delinquency ranges, will create them", e);
existingRanges = new ArrayList<>();
}
for (int i = 0; i < DEFAULT_DELINQUENCY_RANGES.size() - 1; i++) {
String classification = "Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(i).toString();
DelinquencyRangeData existingRange = existingRanges.stream().filter(r -> classification.equals(r.getClassification()))
.findFirst().orElse(null);
if (existingRange != null) {
createdRangeIds.add(existingRange.getId());
continue;
}
DelinquencyRangeRequest postDelinquencyRangeRequest = new DelinquencyRangeRequest();
postDelinquencyRangeRequest.classification(classification);
postDelinquencyRangeRequest.locale(DEFAULT_LOCALE);
if (DEFAULT_DELINQUENCY_RANGES.get(i) == 1) {
postDelinquencyRangeRequest.minimumAgeDays(1);
postDelinquencyRangeRequest.maximumAgeDays(3);
} else {
postDelinquencyRangeRequest.minimumAgeDays(DEFAULT_DELINQUENCY_RANGES.get(i) + 1);
postDelinquencyRangeRequest.maximumAgeDays(DEFAULT_DELINQUENCY_RANGES.get(i + 1));
}
PostDelinquencyRangeResponse response = ok(() -> fineractClient.delinquencyRangeAndBucketsManagement()
.createDelinquencyRange(postDelinquencyRangeRequest, Map.of()));
createdRangeIds.add(response.getResourceId());
}
String lastClassification = "Delinquency range " + DEFAULT_DELINQUENCY_RANGES.get(DEFAULT_DELINQUENCY_RANGES.size() - 1).toString();
DelinquencyRangeData existingLastRange = existingRanges.stream().filter(r -> lastClassification.equals(r.getClassification()))
.findFirst().orElse(null);
if (existingLastRange != null) {
createdRangeIds.add(existingLastRange.getId());
return;
}
DelinquencyRangeRequest lastRange = new DelinquencyRangeRequest();
lastRange.classification(lastClassification);
lastRange.locale(DEFAULT_LOCALE);
lastRange.minimumAgeDays(DEFAULT_DELINQUENCY_RANGES.get(DEFAULT_DELINQUENCY_RANGES.size() - 1) + 1);
lastRange.maximumAgeDays(null);
PostDelinquencyRangeResponse lastResponse = ok(
() -> fineractClient.delinquencyRangeAndBucketsManagement().createDelinquencyRange(lastRange, Map.of()));
createdRangeIds.add(lastResponse.getResourceId());
}
public void setDefaultDelinquencyBucket() {
try {
List<DelinquencyBucketData> existingBuckets = fineractClient.delinquencyRangeAndBucketsManagement()
.getDelinquencyBuckets(Map.of());
boolean bucketExists = existingBuckets.stream().anyMatch(b -> DEFAULT_DELINQUENCY_BUCKET_NAME.equals(b.getName()));
if (bucketExists) {
return;
}
} catch (Exception e) {
log.debug("Could not retrieve existing delinquency buckets, will create default bucket", e);
}
DelinquencyBucketRequest postDelinquencyBucketRequest = new DelinquencyBucketRequest();
postDelinquencyBucketRequest.name(DEFAULT_DELINQUENCY_BUCKET_NAME);
postDelinquencyBucketRequest.ranges(createdRangeIds);
executeVoid(() -> fineractClient.delinquencyRangeAndBucketsManagement().createDelinquencyBucket(postDelinquencyBucketRequest,
Map.of()));
}
}
@@ -1,57 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
import org.apache.fineract.client.models.PostFinancialActivityAccountsRequest;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
public class FinancialActivityMappingGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final Long FINANCIAL_ACTIVITY_ID_ASSET_TRANSFER = 100L;
public static final Long GL_ACCOUNT_ID_ASSET_TRANSFER = 21L;
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
PostFinancialActivityAccountsRequest request = new PostFinancialActivityAccountsRequest()
.financialActivityId(FINANCIAL_ACTIVITY_ID_ASSET_TRANSFER).glAccountId(GL_ACCOUNT_ID_ASSET_TRANSFER);
try {
executeVoid(() -> fineractClient.mappingFinancialActivitiesToAccounts().createGLAccount(request, Map.of()));
log.debug("Financial activity mapping created successfully");
} catch (CallFailedRuntimeException e) {
if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
log.debug("Financial activity mapping already exists, skipping creation");
return;
}
throw e;
}
}
}
@@ -1,71 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.FundData;
import org.apache.fineract.client.models.FundRequest;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
@Order(Ordered.HIGHEST_PRECEDENCE)
public class FundGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String FUNDS_LENDER_A = "Lender A";
public static final String FUNDS_LENDER_B = "Lender B";
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
List<FundData> existingFunds = new ArrayList<>();
try {
existingFunds = fineractClient.funds().retrieveFunds(Map.of());
} catch (Exception e) {
log.debug("Could not retrieve existing funds, will create them", e);
}
final List<FundData> funds = existingFunds;
List<String> fundNames = new ArrayList<>();
fundNames.add(FUNDS_LENDER_A);
fundNames.add(FUNDS_LENDER_B);
fundNames.forEach(name -> {
boolean fundExists = funds.stream().anyMatch(f -> name.equals(f.getName()));
if (fundExists) {
return;
}
FundRequest postFundsRequest = new FundRequest();
postFundsRequest.name(name);
executeVoid(() -> fineractClient.funds().createFund(postFundsRequest, Map.of()));
});
}
}
@@ -1,146 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.GetGLAccountsResponse;
import org.apache.fineract.client.models.PostGLAccountsRequest;
import org.apache.fineract.test.data.GLAType;
import org.apache.fineract.test.data.GLAUsage;
import org.apache.fineract.test.factory.GLAccountRequestFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GLGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final Integer GLA_USAGE_DETAIL = GLAUsage.DETAIL.value;
public static final Integer GLA_TYPE_ASSET = GLAType.ASSET.value;
public static final Integer GLA_TYPE_LIABILITY = GLAType.LIABILITY.value;
public static final Integer GLA_TYPE_INCOME = GLAType.INCOME.value;
public static final Integer GLA_TYPE_EXPENSE = GLAType.EXPENSE.value;
public static final String GLA_NAME_1 = "Loans Receivable";
public static final String GLA_NAME_2 = "Interest/Fee Receivable";
public static final String GLA_NAME_3 = "Other Receivables";
public static final String GLA_NAME_4 = "UNC Receivable";
public static final String GLA_NAME_5 = "AA Suspense Balance";
public static final String GLA_NAME_6 = "Suspense/Clearing account";
public static final String GLA_NAME_7 = "Deferred Interest Revenue";
public static final String GLA_NAME_8 = "Retained Earnings Prior Year";
public static final String GLA_NAME_9 = "Interest Income";
public static final String GLA_NAME_10 = "Fee Income";
public static final String GLA_NAME_11 = "Fee Charge Off";
public static final String GLA_NAME_12 = "Credit Loss/Bad Debt";
public static final String GLA_NAME_13 = "Credit Loss/Bad Debt-Fraud";
public static final String GLA_NAME_14 = "Transfer in suspense account";
public static final String GLA_NAME_15 = "Recoveries";
public static final String GLA_NAME_16 = "Written off";
public static final String GLA_NAME_17 = "Overpayment account";
public static final String GLA_NAME_18 = "Fund Receivables";
public static final String GLA_NAME_19 = "Goodwill Expense Account";
public static final String GLA_NAME_20 = "Interest Income Charge Off";
public static final String GLA_NAME_21 = "Asset transfer";
public static final String GLA_NAME_22 = "Deferred Capitalized Income";
public static final String GLA_NAME_23 = "Buy Down Expense";
public static final String GLA_NAME_24 = "Income From Buy Down";
public static final String GLA_GL_CODE_1 = "112601";
public static final String GLA_GL_CODE_2 = "112603";
public static final String GLA_GL_CODE_3 = "145800";
public static final String GLA_GL_CODE_4 = "245000";
public static final String GLA_GL_CODE_5 = "999999";
public static final String GLA_GL_CODE_6 = "145023";
public static final String GLA_GL_CODE_7 = "240005";
public static final String GLA_GL_CODE_8 = "320000";
public static final String GLA_GL_CODE_9 = "404000";
public static final String GLA_GL_CODE_10 = "404007";
public static final String GLA_GL_CODE_11 = "404008";
public static final String GLA_GL_CODE_12 = "744007";
public static final String GLA_GL_CODE_13 = "744037";
public static final String GLA_GL_CODE_14 = "A5";
public static final String GLA_GL_CODE_15 = "744008";
public static final String GLA_GL_CODE_16 = "e4";
public static final String GLA_GL_CODE_17 = "l1";
public static final String GLA_GL_CODE_18 = "987654";
public static final String GLA_GL_CODE_19 = "744003";
public static final String GLA_GL_CODE_20 = "404001";
public static final String GLA_GL_CODE_21 = "146000";
public static final String GLA_GL_CODE_22 = "145024";
public static final String GLA_GL_CODE_23 = "450280";
public static final String GLA_GL_CODE_24 = "450281";
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
List<GetGLAccountsResponse> existingAccounts = new ArrayList<>();
try {
existingAccounts = fineractClient.generalLedgerAccount().retrieveAllAccountsUniversal(Map.of());
} catch (Exception e) {
log.debug("Could not retrieve existing GL accounts, will create them", e);
}
final List<GetGLAccountsResponse> accounts = existingAccounts;
createGLAccountIfNotExists(accounts, GLA_NAME_1, GLA_GL_CODE_1, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_2, GLA_GL_CODE_2, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_3, GLA_GL_CODE_3, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_4, GLA_GL_CODE_4, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_5, GLA_GL_CODE_5, GLA_TYPE_LIABILITY);
createGLAccountIfNotExists(accounts, GLA_NAME_6, GLA_GL_CODE_6, GLA_TYPE_LIABILITY);
createGLAccountIfNotExists(accounts, GLA_NAME_7, GLA_GL_CODE_7, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_8, GLA_GL_CODE_8, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_9, GLA_GL_CODE_9, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_10, GLA_GL_CODE_10, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_11, GLA_GL_CODE_11, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_12, GLA_GL_CODE_12, GLA_TYPE_EXPENSE);
createGLAccountIfNotExists(accounts, GLA_NAME_13, GLA_GL_CODE_13, GLA_TYPE_EXPENSE);
createGLAccountIfNotExists(accounts, GLA_NAME_14, GLA_GL_CODE_14, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_15, GLA_GL_CODE_15, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_16, GLA_GL_CODE_16, GLA_TYPE_EXPENSE);
createGLAccountIfNotExists(accounts, GLA_NAME_17, GLA_GL_CODE_17, GLA_TYPE_LIABILITY);
createGLAccountIfNotExists(accounts, GLA_NAME_18, GLA_GL_CODE_18, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_19, GLA_GL_CODE_19, GLA_TYPE_EXPENSE);
createGLAccountIfNotExists(accounts, GLA_NAME_20, GLA_GL_CODE_20, GLA_TYPE_INCOME);
createGLAccountIfNotExists(accounts, GLA_NAME_21, GLA_GL_CODE_21, GLA_TYPE_ASSET);
createGLAccountIfNotExists(accounts, GLA_NAME_22, GLA_GL_CODE_22, GLA_TYPE_LIABILITY);
createGLAccountIfNotExists(accounts, GLA_NAME_23, GLA_GL_CODE_23, GLA_TYPE_EXPENSE);
createGLAccountIfNotExists(accounts, GLA_NAME_24, GLA_GL_CODE_24, GLA_TYPE_INCOME);
}
private void createGLAccountIfNotExists(List<GetGLAccountsResponse> existingAccounts, String name, String glCode, Integer type) {
boolean accountExists = existingAccounts.stream().anyMatch(a -> glCode.equals(a.getGlCode()));
if (accountExists) {
return;
}
PostGLAccountsRequest request = GLAccountRequestFactory.defaultGLAccountRequest(name, glCode, type, GLA_USAGE_DETAIL, true);
executeVoid(() -> fineractClient.generalLedgerAccount().createGLAccount1(request, Map.of()));
}
}
@@ -1,52 +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.test.initializer.global;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.test.helper.GlobalConfigurationHelper;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@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_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_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";
private final GlobalConfigurationHelper globalConfigurationHelper;
@Override
public void initialize() throws Exception {
globalConfigurationHelper.disableGlobalConfiguration(CONFIG_KEY_ENABLE_ADDRESS, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_INTEREST_CALCULATION, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_DAYS_BEFORE_REPAYMENT_IS_DUE, 1L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_DAYS_AFTER_REPAYMENT_IS_OVERDUE, 2L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_AUTO_GENERATED_EXTERNAL_ID, 0L);
}
}
@@ -1,87 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.PaymentTypeData;
import org.apache.fineract.client.models.PaymentTypeRequest;
import org.apache.fineract.test.factory.PaymentTypesRequestFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class PaymentTypeGlobalInitializerStep implements FineractGlobalInitializerStep {
public static final String PAYMENT_TYPE_AUTOPAY = "AUTOPAY";
public static final String PAYMENT_TYPE_DOWN_PAYMENT = "DOWN_PAYMENT";
public static final String PAYMENT_TYPE_REAL_TIME = "REAL_TIME";
public static final String PAYMENT_TYPE_SCHEDULED = "SCHEDULED";
public static final String PAYMENT_TYPE_CHECK_PAYMENT = "CHECK_PAYMENT";
public static final String PAYMENT_TYPE_OCA_PAYMENT = "OCA_PAYMENT";
public static final String PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_CHARGEBACK = "REPAYMENT_ADJUSTMENT_CHARGEBACK";
public static final String PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND = "REPAYMENT_ADJUSTMENT_REFUND";
private final FineractFeignClient fineractClient;
@Override
public void initialize() {
List<PaymentTypeData> existingPaymentTypes = new ArrayList<>();
try {
existingPaymentTypes = fineractClient.paymentType().getAllPaymentTypesUniversal(Map.of());
} catch (Exception e) {
log.debug("Could not retrieve existing payment types, will create them", e);
}
final List<PaymentTypeData> paymentTypes = existingPaymentTypes;
List<String> paymentTypeNames = new ArrayList<>();
paymentTypeNames.add(PAYMENT_TYPE_AUTOPAY);
paymentTypeNames.add(PAYMENT_TYPE_DOWN_PAYMENT);
paymentTypeNames.add(PAYMENT_TYPE_REAL_TIME);
paymentTypeNames.add(PAYMENT_TYPE_SCHEDULED);
paymentTypeNames.add(PAYMENT_TYPE_CHECK_PAYMENT);
paymentTypeNames.add(PAYMENT_TYPE_OCA_PAYMENT);
paymentTypeNames.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_CHARGEBACK);
paymentTypeNames.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND);
paymentTypeNames.forEach(paymentTypeName -> {
boolean paymentTypeExists = paymentTypes.stream().anyMatch(pt -> paymentTypeName.equals(pt.getName()));
if (paymentTypeExists) {
return;
}
Integer position = paymentTypeNames.indexOf(paymentTypeName) + 2;
PaymentTypeRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentTypeName,
paymentTypeName, false, position);
executeVoid(() -> fineractClient.paymentType().createPaymentType(postPaymentTypesRequest, Map.of()));
});
}
}
@@ -1,51 +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.test.initializer.global;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@Component
public class SavingsProductGlobalInitializer implements FineractGlobalInitializerStep {
@Override
public void initialize() {
// TODO uncomment and check when PS-1088 is done
// //EUR
// PostSavingsProductsRequest savingsProductsRequestEUR =
// SavingsProductRequestFactory.defaultSavingsProductRequest();
//
// Response<PostSavingsProductsResponse> savingsProductsResponseEUR =
// savingsProductApi.create13(savingsProductsRequestEUR).execute();
// testContext().set(TestContextKey.DEFAULT_SAVINGS_PRODUCT_CREATE_RESPONSE_EUR, savingsProductsResponseEUR);
//
// //USD
// PostSavingsProductsRequest savingsProductsRequestUSD =
// SavingsProductRequestFactory.defaultSavingsProductRequest()
// .name("CUSD")
// .shortName("CUS")
// .currencyCode("USD");
//
// Response<PostSavingsProductsResponse> savingsProductsResponseUSD =
// savingsProductApi.create13(savingsProductsRequestUSD).execute();
// testContext().set(TestContextKey.DEFAULT_SAVINGS_PRODUCT_CREATE_RESPONSE_USD, savingsProductsResponseUSD);
}
}
@@ -1,43 +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.test.initializer.global;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class SchedulerGlobalInitializerStep implements FineractGlobalInitializerStep {
private static final String SCHEDULER_STATUS_STOP = "stop";
private final FineractFeignClient fineractClient;
@Override
public void initialize() throws Exception {
executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus(Map.of("command", SCHEDULER_STATUS_STOP)));
}
}
@@ -1,50 +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.test.initializer.scenario;
import static org.apache.fineract.test.initializer.global.GlobalConfigurationGlobalInitializerStep.CONFIG_KEY_ENABLE_ADDRESS;
import static org.apache.fineract.test.initializer.global.GlobalConfigurationGlobalInitializerStep.CONFIG_KEY_ENABLE_BUSINESS_DATE;
import static org.apache.fineract.test.initializer.global.GlobalConfigurationGlobalInitializerStep.CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.test.helper.GlobalConfigurationHelper;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class GlobalConfigurationScenarioInitializerStep implements FineractScenarioInitializerStep {
private final GlobalConfigurationHelper globalConfigurationHelper;
@Override
public void initializeForScenario() throws Exception {
// Enable-address set to false
globalConfigurationHelper.disableGlobalConfiguration(CONFIG_KEY_ENABLE_ADDRESS, 0L);
// Enable business date and COB date
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
globalConfigurationHelper.enableGlobalConfiguration(CONFIG_KEY_ENABLE_RECALCULATE_COB_DATE, 0L);
}
@Override
public void resetAfterScenario() {
// Enable business date
globalConfigurationHelper.disableGlobalConfiguration(CONFIG_KEY_ENABLE_BUSINESS_DATE, 0L);
}
}
@@ -1,98 +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.test.initializer.suite;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import static org.awaitility.Awaitility.await;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ExternalEventConfigurationItemResponse;
import org.apache.fineract.client.models.ExternalEventConfigurationResponse;
import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest;
import org.apache.fineract.test.messaging.config.EventProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.config.JmsListenerEndpointRegistry;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.stereotype.Component;
@Slf4j
@RequiredArgsConstructor
@Component
public class ExternalEventSuiteInitializerStep implements FineractSuiteInitializerStep {
private static final Duration JMS_STARTUP_TIMEOUT = Duration.ofSeconds(30);
private final FineractFeignClient fineractClient;
@Autowired(required = false)
private JmsListenerEndpointRegistry registry;
@Autowired(required = false)
private EventProperties eventProperties;
@Override
public void initializeForSuite() throws InterruptedException {
log.debug("=== ExternalEventSuiteInitializerStep.initializeForSuite() - START ===");
// Step 1: Enable all external events
Map<String, Boolean> eventConfigMap = new HashMap<>();
ExternalEventConfigurationResponse response = ok(
() -> fineractClient.externalEventConfiguration().getExternalEventConfigurations(Map.of()));
List<ExternalEventConfigurationItemResponse> externalEventConfiguration = response.getExternalEventConfiguration();
externalEventConfiguration.forEach(e -> {
eventConfigMap.put(e.getType(), true);
});
ExternalEventConfigurationUpdateRequest request = new ExternalEventConfigurationUpdateRequest()
.externalEventConfigurations(eventConfigMap);
executeVoid(() -> fineractClient.externalEventConfiguration().updateExternalEventConfigurations(null, request, Map.of()));
log.debug("=== External event configuration updated - all events enabled ===");
// Step 2: Wait for JMS Listener to be ready before proceeding
if (eventProperties != null && eventProperties.isEventVerificationEnabled()) {
if (registry == null) {
log.warn("=== JmsListenerEndpointRegistry not available - skipping JMS listener readiness check ===");
log.warn("=== This is expected in CI environments where JMS may not be fully initialized during suite setup ===");
} else {
log.info("=== Waiting for JMS Listener to connect to ActiveMQ (max {}s) ===", JMS_STARTUP_TIMEOUT.toSeconds());
DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) registry
.getListenerContainer("eventStoreListener");
if (container == null) {
log.warn("=== JMS Listener container 'eventStoreListener' not found - event verification may not work ===");
} else {
await().atMost(JMS_STARTUP_TIMEOUT).pollInterval(Duration.ofMillis(200)).until(container::isRunning);
log.info("=== JMS Listener is running and ready to receive events ===");
}
}
}
log.debug("=== ExternalEventSuiteInitializerStep.initializeForSuite() - COMPLETED ===");
}
}
@@ -1,132 +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.test.initializer.suite;
import static org.apache.fineract.client.feign.util.FeignCalls.executeVoid;
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.feign.FineractFeignClient;
import org.apache.fineract.client.models.ExecuteJobRequest;
import org.apache.fineract.client.models.GetJobsResponse;
import org.apache.fineract.client.models.PutJobsJobIDRequest;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class JobSuiteInitializerStep implements FineractSuiteInitializerStep {
public static final String SEND_ASYNCHRONOUS_EVENTS_JOB_NAME = "Send Asynchronous Events";
public static final String EVERY_1_SECONDS = "0/1 * * * * ?";
public static final String EVERY_60_SECONDS = "0 0/1 * * * ?";
private final FineractFeignClient fineractClient;
public JobSuiteInitializerStep(FineractFeignClient fineractClient) {
log.debug("=== JobSuiteInitializerStep: Constructor called - bean is being created ===");
this.fineractClient = fineractClient;
log.debug("=== JobSuiteInitializerStep: FineractFeignClient injected successfully ===");
}
@Override
public void initializeForSuite() throws InterruptedException {
log.debug("=== JobSuiteInitializerStep.initializeForSuite() - START ===");
enableAndExecuteEventJob();
log.debug("=== JobSuiteInitializerStep.initializeForSuite() - COMPLETED successfully ===");
}
private void enableAndExecuteEventJob() throws InterruptedException {
log.debug("=== Initializing Send Asynchronous Events job ===");
Long jobId = updateExternalEventJobFrequency(EVERY_1_SECONDS);
log.debug("=== Updated cron expression to EVERY_1_SECONDS ===");
// CRITICAL: SchedulerGlobalInitializerStep stops the scheduler globally
// Solution: START the scheduler so the job runs every 1 second automatically
log.debug("Starting scheduler to enable automatic job execution every 1 second...");
executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus("start", Map.of()));
log.debug("Scheduler started successfully");
// Manually execute once immediately to publish any queued events from initialization
log.debug("Manually executing '{}' job once to publish queued events...", SEND_ASYNCHRONOUS_EVENTS_JOB_NAME);
executeVoid(() -> fineractClient.schedulerJob().executeJob(jobId, new ExecuteJobRequest(), Map.of("command", "executeJob")));
// Poll job history to confirm it ran
log.debug("Polling job history to confirm initial execution...");
Long initialRunCount = getJobRunCount(jobId);
log.debug("Initial job run count: {}", initialRunCount);
boolean jobRan = false;
for (int i = 0; i < 30; i++) {
Thread.sleep(200);
Long currentRunCount = getJobRunCount(jobId);
if (currentRunCount > initialRunCount) {
log.debug("Job execution confirmed! Run count increased from {} to {}", initialRunCount, currentRunCount);
jobRan = true;
break;
}
}
if (!jobRan) {
log.warn("WARNING: Job execution could not be confirmed via history polling");
}
// Wait for events to propagate to ActiveMQ
log.debug("Waiting 1 second for event propagation to ActiveMQ...");
Thread.sleep(1000);
log.debug("Scheduler is now running - job will execute every 1 second automatically");
}
private Long getJobRunCount(Long jobId) {
try {
var history = ok(() -> fineractClient.schedulerJob().retrieveHistory(jobId, Map.of()));
return (long) history.getTotalFilteredRecords();
} catch (Exception e) {
log.warn("Failed to retrieve job history: {}", e.getMessage());
return 0L;
}
}
@Override
public void resetAfterSuite() {
log.debug("=== JobSuiteInitializerStep.resetAfterSuite() - START ===");
// Stop the scheduler to prevent jobs from running between test suites
log.debug("Stopping scheduler...");
try {
executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus(Map.of("command", "stop")));
log.debug("Scheduler stopped successfully");
} catch (Exception e) {
log.warn("Failed to stop scheduler: {}", e.getMessage());
}
// Reset cron expression to default
updateExternalEventJobFrequency(EVERY_60_SECONDS);
log.debug("=== JobSuiteInitializerStep.resetAfterSuite() - COMPLETED ===");
}
private Long updateExternalEventJobFrequency(String cronExpression) {
GetJobsResponse externalEventJobResponse = ok(() -> fineractClient.schedulerJob().retrieveAll8()).stream()
.filter(r -> r.getDisplayName().equals(SEND_ASYNCHRONOUS_EVENTS_JOB_NAME)).findAny()
.orElseThrow(() -> new IllegalStateException(SEND_ASYNCHRONOUS_EVENTS_JOB_NAME + " is not found"));
Long jobId = externalEventJobResponse.getJobId();
executeVoid(() -> fineractClient.schedulerJob().updateJobDetail(jobId, new PutJobsJobIDRequest().cronExpression(cronExpression)));
return jobId;
}
}
@@ -143,7 +143,6 @@ import org.apache.fineract.test.helper.BusinessDateHelper;
import org.apache.fineract.test.helper.CodeHelper;
import org.apache.fineract.test.helper.ErrorMessageHelper;
import org.apache.fineract.test.helper.Utils;
import org.apache.fineract.test.initializer.global.LoanProductGlobalInitializerStep;
import org.apache.fineract.test.messaging.EventAssertion;
import org.apache.fineract.test.messaging.config.EventProperties;
import org.apache.fineract.test.messaging.config.JobPollingProperties;
@@ -3213,8 +3212,8 @@ public class LoanStepDef extends AbstractStepDef {
if (transactionTypeToChange.equals(transactionTypeOriginal)) {
futureInstallmentAllocationRule = futureInstallmentAllocationRuleNew;
}
newPaymentAllocation.add(LoanProductGlobalInitializerStep.editPaymentAllocationFutureInstallment(transactionTypeOriginal,
futureInstallmentAllocationRule, paymentAllocationOrder));
newPaymentAllocation.add(editPaymentAllocationFutureInstallment(transactionTypeOriginal, futureInstallmentAllocationRule,
paymentAllocationOrder));
});
PutLoanProductsProductIdRequest putLoanProductsProductIdRequest = new PutLoanProductsProductIdRequest()
@@ -5907,4 +5906,14 @@ public class LoanStepDef extends AbstractStepDef {
assertEquals(Integer.valueOf(numberOfRelations), relationshipOptional.size(), "Missed relationship for transaction");
}
public static AdvancedPaymentData editPaymentAllocationFutureInstallment(String transactionType, String futureInstallmentAllocationRule,
List<PaymentAllocationOrder> paymentAllocationOrder) {
AdvancedPaymentData advancedPaymentData = new AdvancedPaymentData();
advancedPaymentData.setTransactionType(transactionType);
advancedPaymentData.setFutureInstallmentAllocationRule(futureInstallmentAllocationRule);
advancedPaymentData.setPaymentAllocationOrder(paymentAllocationOrder);
return advancedPaymentData;
}
}