FINERACT-2421: Refractor redundant and some deprecated code as per new Java 21 style (Phase 3)

This commit is contained in:
Aman-Mittal
2025-12-26 19:27:38 +01:00
committed by Adam Saghy
parent 7dac82a4fc
commit 0ba1745443
18 changed files with 82 additions and 145 deletions
@@ -24,12 +24,11 @@ import org.apache.fineract.cob.domain.BatchBusinessStep;
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
@Mapper(config = MapstructMapperConfig.class)
public interface BusinessStepMapper {
@Mappings({ @Mapping(target = "order", source = "source.stepOrder") })
@Mapping(target = "order", source = "source.stepOrder")
BusinessStep map(BatchBusinessStep source);
List<BusinessStep> map(List<BatchBusinessStep> source);
@@ -25,7 +25,6 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DefaultValue;
@@ -63,13 +62,14 @@ import org.springframework.stereotype.Component;
*/
@Path("/v1/batches")
@Component
@Tag(name = "Batch API", description = "The Apache Fineract Batch API enables a consumer to access significant amounts of data in a single call or to make changes to several objects at once. Batching allows a consumer to pass instructions for several operations in a single HTTP request. A consumer can also specify dependencies between related operations. Once all operations have been completed, a consolidated response will be passed back and the HTTP connection will be closed.\n"
+ "\n"
+ "The Batch API takes in an array of logical HTTP requests represented as JSON arrays - each request has a requestId (the id of a request used to specify the sequence and as a dependency between requests), a method (corresponding to HTTP method GET/PUT/POST/DELETE etc.), a relativeUrl (the portion of the URL after https://example.org/api/v2/), optional headers array (corresponding to HTTP headers), optional reference parameter if a request is dependent on another request and an optional body (for POST and PUT requests). The Batch API returns an array of logical HTTP responses represented as JSON arrays - each response has a requestId, a status code, an optional headers array and an optional body (which is a JSON encoded string).\n"
+ "\n"
+ "Batch API uses Json Path to handle dependent parameters. For example, if request '2' is referencing request '1' and in the \"body\" or in \"relativeUrl\" of request '2', there is a dependent parameter (which will look like \"$.parameter_name\"), then Batch API will internally substitute this dependent parameter from the response body of request '1'.\n"
+ "\n"
+ "Batch API is able to handle deeply nested dependent requests as well nested parameters. As shown in the example, requests are dependent on each other as, 1<--2<--6, i.e a nested dependency, where request '6' is not directly dependent on request '1' but still it is one of the nested child of request '1'. In the same way Batch API could handle a deeply nested dependent value, such as {..[..{..,$.parameter_name,..}..]}.")
@Tag(name = "Batch API", description = """
The Apache Fineract Batch API enables a consumer to access significant amounts of data in a single call or to make changes to several objects at once. Batching allows a consumer to pass instructions for several operations in a single HTTP request. A consumer can also specify dependencies between related operations. Once all operations have been completed, a consolidated response will be passed back and the HTTP connection will be closed.
The Batch API takes in an array of logical HTTP requests represented as JSON arrays - each request has a requestId (the id of a request used to specify the sequence and as a dependency between requests), a method (corresponding to HTTP method GET/PUT/POST/DELETE etc.), a relativeUrl (the portion of the URL after https://example.org/api/v2/), optional headers array (corresponding to HTTP headers), optional reference parameter if a request is dependent on another request and an optional body (for POST and PUT requests). The Batch API returns an array of logical HTTP responses represented as JSON arrays - each response has a requestId, a status code, an optional headers array and an optional body (which is a JSON encoded string).
Batch API uses Json Path to handle dependent parameters. For example, if request '2' is referencing request '1' and in the "body" or in "relativeUrl" of request '2', there is a dependent parameter (which will look like "$.parameter_name"), then Batch API will internally substitute this dependent parameter from the response body of request '1'.
Batch API is able to handle deeply nested dependent requests as well nested parameters. As shown in the example, requests are dependent on each other as, 1<--2<--6, i.e a nested dependency, where request '6' is not directly dependent on request '1' but still it is one of the nested child of request '1'. In the same way Batch API could handle a deeply nested dependent value, such as {..[..{..,$.parameter_name,..}..]}.""")
@RequiredArgsConstructor
public class BatchApiResource {
@@ -88,12 +88,12 @@ public class BatchApiResource {
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Batch requests in a single transaction", description = "The Apache Fineract Batch API is also capable of executing all the requests in a single transaction, by setting a Query Parameter, \"enclosingTransaction=true\". So, if one or more of the requests in a batch returns an erroneous response all of the Data base transactions made by other successful requests will be rolled back.\n"
+ "\n"
+ "If there has been a rollback in a transaction then a single response will be provided, with a '400' status code and a body consisting of the error details of the first failed request.")
@Operation(summary = "Batch requests in a single transaction", description = """
The Apache Fineract Batch API is also capable of executing all the requests in a single transaction, by setting a Query Parameter, "enclosingTransaction=true". So, if one or more of the requests in a batch returns an erroneous response all of the Data base transactions made by other successful requests will be rolled back.
If there has been a rollback in a transaction then a single response will be provided, with a '400' status code and a body consisting of the error details of the first failed request.""")
@RequestBody(required = true, content = @Content(array = @ArraySchema(schema = @Schema(implementation = BatchRequest.class, description = "request body"))))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Success", content = @Content(array = @ArraySchema(schema = @Schema(implementation = BatchResponse.class)))) })
@ApiResponse(responseCode = "200", description = "Success", content = @Content(array = @ArraySchema(schema = @Schema(implementation = BatchResponse.class))))
public List<BatchResponse> handleBatchRequests(
@DefaultValue("false") @QueryParam("enclosingTransaction") @Parameter(description = "enclosingTransaction", required = false) final boolean enclosingTransaction,
@Parameter(hidden = true) List<BatchRequest> requestList, @Context UriInfo uriInfo) {
@@ -45,7 +45,6 @@ public class BatchRequestJsonHelper extends FromJsonHelper {
*/
public List<BatchRequest> extractList(final String json) {
final Type listType = new TypeToken<List<BatchRequest>>() {}.getType();
final List<BatchRequest> requests = super.getGsonConverter().fromJson(json, listType);
return requests;
return super.getGsonConverter().fromJson(json, listType);
}
}
@@ -20,7 +20,9 @@ package org.apache.fineract.infrastructure.bulkimport.data;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
@Getter
public enum GlobalEntityType {
INVALID(0, "invalid"), //
@@ -91,27 +93,17 @@ public enum GlobalEntityType {
this.code = code;
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public static GlobalEntityType fromInt(final int i) {
final GlobalEntityType entityType = intToEnumMap.get(Integer.valueOf(i));
return entityType;
return intToEnumMap.get(i);
}
public static GlobalEntityType fromCode(final String key) {
final GlobalEntityType entityType = stringToEnumMap.get(key);
return entityType;
return stringToEnumMap.get(key);
}
@Override
public String toString() {
return name().toString();
return name();
}
}
@@ -27,12 +27,12 @@ import org.apache.fineract.infrastructure.businessdate.domain.BusinessDate;
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
@Mapper(config = MapstructMapperConfig.class)
public interface BusinessDateMapper {
@Mappings({ @Mapping(target = "description", source = "type.description"), @Mapping(target = "changes", ignore = true) })
@Mapping(target = "description", source = "type.description")
@Mapping(target = "changes", ignore = true)
BusinessDateDTO mapEntity(BusinessDate source);
List<BusinessDateDTO> mapEntity(List<BusinessDate> sources);
@@ -50,10 +50,7 @@ public class ApplicationCurrencyRepositoryWrapper {
throw new CurrencyNotFoundException(currency.getCode());
}
final ApplicationCurrency applicationCurrency = ApplicationCurrency.from(defaultApplicationCurrency,
currency.getDigitsAfterDecimal(), currency.getInMultiplesOf());
return applicationCurrency;
return ApplicationCurrency.from(defaultApplicationCurrency, currency.getDigitsAfterDecimal(), currency.getInMultiplesOf());
}
/**
@@ -72,7 +72,7 @@ public final class AnnualCompoundingPeriod implements CompoundingPeriod {
final BigDecimal minOverdraftForInterestCalculation) {
BigDecimal cumulativeBalance = BigDecimal.ZERO;
Integer numberOfDays = Integer.valueOf(0);
Integer numberOfDays = 0;
for (final EndOfDayBalance balance : this.endOfDayBalances) {
final BigDecimal endOfDayCumulativeBalance = balance.cumulativeBalance(interestToCompound);
@@ -126,28 +126,10 @@ public final class AnnualCompoundingPeriod implements CompoundingPeriod {
daysInYear, minBalanceForInterestCalculation, overdraftInterestRateAsFraction,
minOverdraftForInterestCalculation);
break;
case MONTHLY:
case MONTHLY, ANNUAL, BI_ANNUAL, QUATERLY:
interestOnBalanceUnrounded = balance.calculateInterestOnBalance(interestToCompound, interestRateAsFraction, daysInYear,
minBalanceForInterestCalculation, overdraftInterestRateAsFraction, minOverdraftForInterestCalculation);
break;
case QUATERLY:
interestOnBalanceUnrounded = balance.calculateInterestOnBalance(interestToCompound, interestRateAsFraction, daysInYear,
minBalanceForInterestCalculation, overdraftInterestRateAsFraction, minOverdraftForInterestCalculation);
break;
// case WEEKLY:
// break;
// case BIWEEKLY:
// break;
case BI_ANNUAL:
interestOnBalanceUnrounded = balance.calculateInterestOnBalance(interestToCompound, interestRateAsFraction, daysInYear,
minBalanceForInterestCalculation, overdraftInterestRateAsFraction, minOverdraftForInterestCalculation);
break;
case ANNUAL:
interestOnBalanceUnrounded = balance.calculateInterestOnBalance(interestToCompound, interestRateAsFraction, daysInYear,
minBalanceForInterestCalculation, overdraftInterestRateAsFraction, minOverdraftForInterestCalculation);
break;
// case NO_COMPOUNDING_SIMPLE_INTEREST:
// break;
case INVALID:
break;
}
@@ -20,7 +20,10 @@ package org.apache.fineract.useradministration.data;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import org.apache.fineract.organisation.office.data.OfficeData;
import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.portfolio.client.data.ClientData;
@@ -43,6 +46,7 @@ public final class AppUserData {
private List<Long> roles;
private Boolean sendPasswordToEmail;
private Long staffId;
@Getter
private transient Integer rowIndex;
@SuppressWarnings("unused")
@@ -53,6 +57,7 @@ public final class AppUserData {
private final StaffData staff;
private final Boolean isSelfServiceUser;
@Setter
@SuppressWarnings("unused")
private Set<ClientData> clients;
@@ -85,10 +90,6 @@ public final class AppUserData {
this.clients = null;
}
public Integer getRowIndex() {
return rowIndex;
}
public static AppUserData template(final AppUserData user, final Collection<OfficeData> officesForDropdown) {
return new AppUserData(user.id, user.username, user.email, user.officeId, user.officeName, user.firstname, user.lastname,
user.availableRoles, user.selfServiceRoles, user.selectedRoles, officesForDropdown, user.staff, user.passwordNeverExpires,
@@ -146,17 +147,11 @@ public final class AppUserData {
if (this == o) {
return true;
}
if (o == null || !(o instanceof AppUserData)) {
if (!(o instanceof AppUserData that)) {
return false;
}
AppUserData that = (AppUserData) o;
if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}
return true;
return Objects.equals(id, that.id);
}
@Override
@@ -164,12 +159,8 @@ public final class AppUserData {
return id != null ? id.hashCode() : 0;
}
public void setClients(Set<ClientData> clients) {
this.clients = clients;
}
public boolean isSelfServiceUser() {
return this.isSelfServiceUser == null ? false : this.isSelfServiceUser;
return this.isSelfServiceUser != null && this.isSelfServiceUser;
}
}
@@ -72,7 +72,7 @@ public class AppUserClientMapping extends AbstractPersistableCustom<Long> {
AppUserClientMapping that = (AppUserClientMapping) obj;
return null == this.client.getId() ? false : this.client.getId().equals(that.client.getId());
return null != this.client.getId() && this.client.getId().equals(that.client.getId());
}
@Override
@@ -101,9 +101,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
final DocumentCommand documentCommand = new DocumentCommand(null, null, entityType, entityId, name, fileName, fileSize, mimeType,
description, null);
final Long documentId = createDocument(documentCommand, inputStream);
return documentId;
return createDocument(documentCommand, inputStream);
}
@@ -196,7 +194,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
@Override
public String toString() {
return name().toString().toLowerCase();
return name().toLowerCase();
}
}
}
@@ -645,11 +645,8 @@ public class AssetExternalizationStepDef extends AbstractStepDef {
PageExternalTransferData transfersResponse = externalAssetOwnersApi().getTransfers(Map.of("loanId", loanId));
List<ExternalTransferData> content = transfersResponse.getContent();
ExternalTransferData result = content.stream().filter(bizEvent -> bizEvent.getTransferExternalId().equals(transferExternalId))
.toList().stream().reduce((first, second) -> second)
.orElseThrow(() -> new IllegalStateException("transfersResponse.getContent() is empty"));
return result;
return content.stream().filter(bizEvent -> bizEvent.getTransferExternalId().equals(transferExternalId)).toList().stream()
.reduce((first, second) -> second).orElseThrow(() -> new IllegalStateException("transfersResponse.getContent() is empty"));
}
@Then("The asset external owner has the following OWNER Journal entries:")
@@ -21,7 +21,6 @@ package org.apache.fineract.investor.service;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -29,9 +28,9 @@ import static org.mockito.Mockito.when;
import com.google.gson.JsonElement;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Stream;
import lombok.Setter;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
@@ -107,7 +106,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
// then
verify(testContext.loanProductRepository).existsById(testContext.loanProductId);
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(eq(command.entityId()));
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(command.entityId());
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).saveAndFlush(loanProductAttributeArgumentCaptor.capture());
}
@@ -134,7 +133,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
// then
verify(testContext.loanProductRepository).existsById(testContext.loanProductId);
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(eq(command.entityId()));
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(command.entityId());
verify(testContext.externalAssetOwnerLoanProductAttributesRepository, times(0))
.saveAndFlush(loanProductAttributeArgumentCaptor.capture());
}
@@ -157,7 +156,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
// then
verify(testContext.loanProductRepository).existsById(testContext.loanProductId);
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(eq(1L));
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(1L);
verify(testContext.externalAssetOwnerLoanProductAttributesRepository, times(0))
.saveAndFlush(loanProductAttributeArgumentCaptor.capture());
Assertions.assertEquals(thrownException.getMessage(), "Loan product attribute with id " + 1L + " was not found");
@@ -188,7 +187,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
// then
verify(testContext.loanProductRepository).existsById(testContext.loanProductId);
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(eq(command.entityId()));
verify(testContext.externalAssetOwnerLoanProductAttributesRepository).findById(command.entityId());
verify(testContext.externalAssetOwnerLoanProductAttributesRepository, times(0))
.saveAndFlush(loanProductAttributeArgumentCaptor.capture());
Assertions.assertEquals(thrownException.getMessage(),
@@ -365,7 +364,7 @@ public class ExternalAssetOwnerLoanProductAttributesWriteServiceImplTest {
private ExternalAssetOwnerLoanProductAttributesWriteServiceImpl externalAssetOwnerLoanProductAttributesWriteService;
private final FromJsonHelper fromJsonHelper = new FromJsonHelper();
private final Long loanProductId = Long.valueOf(RandomStringUtils.randomNumeric(2));
private final Long loanProductId = ThreadLocalRandom.current().nextLong(10, 100);
@Setter
private String attributeKey = "SETTLEMENT_MODEL";
@Setter
@@ -3150,9 +3150,8 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
.orElse(null);
final List<LoanCharge> liftedLoanCharges = new ArrayList<>();
installments.stream().filter(installment -> !installment.getDueDate().isBefore(transactionDate)).forEach(i -> {
liftedLoanCharges.addAll(getLoanChargesOfInstallment(ctx.getCharges(), i, 1));
});
installments.stream().filter(installment -> !installment.getDueDate().isBefore(transactionDate))
.forEach(i -> liftedLoanCharges.addAll(getLoanChargesOfInstallment(ctx.getCharges(), i, 1)));
installments.removeIf(i -> i.getInstallmentNumber() != null && !i.isDownPayment() && !i.getDueDate().isBefore(transactionDate));
@@ -3308,10 +3307,10 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private LocalDate calculateReAgedNextDate(final PeriodFrequencyType frequencyType, final LocalDate dueDate,
final Integer frequencyNumber) {
return switch (frequencyType) {
case DAYS -> dueDate.plusDays((long) frequencyNumber);
case WEEKS -> dueDate.plusWeeks((long) frequencyNumber);
case MONTHS -> dueDate.plusMonths((long) frequencyNumber);
case YEARS -> dueDate.plusYears((long) frequencyNumber);
case DAYS -> dueDate.plusDays(frequencyNumber);
case WEEKS -> dueDate.plusWeeks(frequencyNumber);
case MONTHS -> dueDate.plusMonths(frequencyNumber);
case YEARS -> dueDate.plusYears(frequencyNumber);
default -> throw new UnsupportedOperationException();
};
}
@@ -3799,10 +3798,8 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private void createChargeMappingsForInstallment(final LoanRepaymentScheduleInstallment installment,
List<ReAgedChargeEqualAmortizationValues> reAgedChargeEqualAmortizationValues, Integer index) {
reAgedChargeEqualAmortizationValues.forEach(amortizationValue -> {
installment.getInstallmentCharges().add(new LoanInstallmentCharge(
amortizationValue.equalAmortizationValues.calculateValueBigDecimal(index), amortizationValue.charge, installment));
});
reAgedChargeEqualAmortizationValues.forEach(amortizationValue -> installment.getInstallmentCharges().add(new LoanInstallmentCharge(
amortizationValue.equalAmortizationValues.calculateValueBigDecimal(index), amortizationValue.charge, installment)));
}
private FirstReAgeInstallmentProps calculateFirstReAgeInstallmentProps(List<LoanRepaymentScheduleInstallment> installments,
@@ -78,9 +78,8 @@ public class AdvancedPaymentAllocationsValidator {
AtomicInteger pastDueRuleInteger = new AtomicInteger();
AtomicInteger dueRuleInteger = new AtomicInteger();
AtomicInteger inAdvanceRuleInteger = new AtomicInteger();
paymentAllocationRule.getAllocationTypes().forEach(paymentAllocationType -> {
validateAllocationType(paymentAllocationType, pastDueRuleInteger, dueRuleInteger, inAdvanceRuleInteger);
});
paymentAllocationRule.getAllocationTypes().forEach(paymentAllocationType -> validateAllocationType(paymentAllocationType,
pastDueRuleInteger, dueRuleInteger, inAdvanceRuleInteger));
});
}
@@ -122,14 +121,14 @@ public class AdvancedPaymentAllocationsValidator {
}
private boolean hasAtLeastOneDefaultPaymentAllocation(List<LoanProductPaymentAllocationRule> rules) {
return rules != null && rules.stream() //
return rules != null && !rules.stream() //
.filter(r -> PaymentAllocationTransactionType.DEFAULT.equals(r.getTransactionType())) //
.toList() //
.size() > 0;
.isEmpty();
}
private boolean hasLoanProductPaymentAllocationRule(List<LoanProductPaymentAllocationRule> rules) {
return rules != null && rules.size() > 0;
return rules != null && !rules.isEmpty();
}
private void raiseValidationError(String globalisationMessageCode, String msg) {
@@ -258,12 +258,12 @@ class AdvancedPaymentScheduleTransactionProcessorTest {
when(loan.getPaymentAllocationRules()).thenReturn(List.of(loanPaymentAllocationRule));
when(loanPaymentAllocationRule.getTransactionType()).thenReturn(PaymentAllocationTransactionType.DEFAULT);
when(loanPaymentAllocationRule.getAllocationTypes()).thenReturn(List.of(PaymentAllocationType.DUE_PRINCIPAL));
when(loanTransaction.isOn(eq(transactionDate))).thenReturn(true);
when(loanTransaction.isOn(transactionDate)).thenReturn(true);
underTest.processLatestTransaction(loanTransaction,
new TransactionCtx(currency, List.of(installment), Set.of(charge), new MoneyHolder(overpaidAmount), null));
Mockito.verify(installment, times(1)).payFeeChargesComponent(eq(transactionDate), eq(chargeAmountMoney));
Mockito.verify(installment, times(1)).payFeeChargesComponent(transactionDate, chargeAmountMoney);
Mockito.verify(loanTransaction, times(1)).updateComponents(refEq(zero), refEq(zero), refEq(chargeAmountMoney), refEq(zero));
assertEquals(0, BigDecimal.valueOf(20).compareTo(loanTransaction.getAmount(currency).minus(chargeAmountMoney).getAmount()));
assertEquals(0, chargeAmount.compareTo(installment.getFeeChargesCharged(currency).getAmount()));
@@ -220,18 +220,15 @@ class AdvancedPaymentAllocationsJsonParserTest {
private static List<Pair<Integer, PaymentAllocationType>> createPaymentAllocationTypeList() {
AtomicInteger i = new AtomicInteger(1);
List<Pair<Integer, PaymentAllocationType>> list = EnumSet.allOf(PaymentAllocationType.class).stream()
.map(p -> Pair.of(i.getAndIncrement(), p)).toList();
return list;
return EnumSet.allOf(PaymentAllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p)).toList();
}
@NonNull
private JsonCommand createJsonCommand(Map<String, Object> jsonMap) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonMap);
JsonCommand command = JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null,
null, null, null, null, null, null);
return command;
return JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null, null, null,
null, null, null, null);
}
}
@@ -280,16 +280,14 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
return offices;
}
@SuppressWarnings("unchecked")
private List<ChargeData> fetchCharges() {
return (List) this.chargeReadPlatformService.retrieveAllCharges();
return this.chargeReadPlatformService.retrieveAllCharges();
}
@SuppressWarnings("unchecked")
private List<StaffData> fetchStaff(final Long staffId) {
List<StaffData> staff = null;
if (staffId == null) {
staff = (List) this.staffReadPlatformService.retrieveAllStaff(null, Boolean.FALSE, null);
staff = this.staffReadPlatformService.retrieveAllStaff(null, Boolean.FALSE, null);
} else {
staff = new ArrayList<>();
staff.add(this.staffReadPlatformService.retrieveStaff(staffId));
@@ -308,8 +306,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
}
private List<SavingsProductData> fetchSavingsProducts() {
List<SavingsProductData> savingsProducts = (List<SavingsProductData>) savingsProductReadPlatformService.retrieveAll();
return savingsProducts;
return (List<SavingsProductData>) savingsProductReadPlatformService.retrieveAll();
}
private WorkbookPopulator populateCenterWorkbook(Long officeId, Long staffId) {
@@ -396,23 +393,19 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
}
private List<CurrencyData> fetchCurrencies() {
List<CurrencyData> currencies = (List<CurrencyData>) this.currencyReadPlatformService.retrieveAllPlatformCurrencies();
return currencies;
return this.currencyReadPlatformService.retrieveAllPlatformCurrencies();
}
private List<PaymentTypeData> fetchPaymentTypes() {
List<PaymentTypeData> paymentTypeData = (List<PaymentTypeData>) this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
return paymentTypeData;
return this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
}
private List<FundData> fetchFunds() {
List<FundData> funds = (List<FundData>) this.fundReadPlatformService.retrieveAllFunds();
return funds;
return this.fundReadPlatformService.retrieveAllFunds();
}
private List<LoanProductData> fetchLoanProducts() {
List<LoanProductData> loanproducts = (List<LoanProductData>) this.loanProductReadPlatformService.retrieveAllLoanProducts();
return loanproducts;
return (List<LoanProductData>) this.loanProductReadPlatformService.retrieveAllLoanProducts();
}
private List<GroupGeneralData> fetchGroups(Long officeId) {
@@ -470,8 +463,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
}
private List<GLAccountData> fetchGLAccounts() {
List<GLAccountData> glaccounts = this.glAccountReadPlatformService.retrieveAllGLAccounts(null, null, null, null, null, null);
return glaccounts;
return this.glAccountReadPlatformService.retrieveAllGLAccounts(null, null, null, null, null, null);
}
private WorkbookPopulator populateGuarantorWorkbook(Long officeId) {
@@ -504,12 +496,12 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
return new OfficeWorkbookPopulator(offices);
}
// TODO: officeId seems to be unused and used in getTemplate() needs to be evaluated and removed
private WorkbookPopulator populateChartOfAccountsWorkbook(Long officeId) {
this.context.authenticatedUser().validateHasReadPermission(TemplatePopulateImportConstants.GL_ACCOUNT_ENTITY_TYPE);
List<GLAccountData> glAccounts = fetchGLAccounts();
List<OfficeData> offices = fetchOffices(null);
return new ChartOfAccountsWorkbook(glAccounts, offices,
(List<CurrencyData>) this.currencyReadPlatformService.retrieveAllowedCurrencies());
return new ChartOfAccountsWorkbook(glAccounts, offices, this.currencyReadPlatformService.retrieveAllowedCurrencies());
}
private WorkbookPopulator populateStaffWorkbook(Long officeId) {
@@ -531,8 +523,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
}
private List<ChargeData> fetchChargesForShares() {
List<ChargeData> chargesForShares = (List<ChargeData>) chargeReadPlatformService.retrieveSharesApplicableCharges();
return chargesForShares;
return chargeReadPlatformService.retrieveSharesApplicableCharges();
}
private List<ShareProductData> fetchSharedProducts() {
@@ -655,8 +646,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
}
private List<RoleData> fetchRoles() {
List<RoleData> rolesList = (List<RoleData>) roleReadPlatformService.retrieveAllActiveRoles();
return rolesList;
return (List<RoleData>) roleReadPlatformService.retrieveAllActiveRoles();
}
private WorkbookPopulator populateFixedDepositTransactionsWorkbook(Long officeId) {
@@ -40,8 +40,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.fineract.batch.command.internal.AdjustLoanTransactionCommandStrategy;
import org.apache.fineract.batch.command.internal.CreateTransactionLoanCommandStrategy;
import org.apache.fineract.batch.command.internal.GetDatatableEntryByAppTableIdAndDataTableIdCommandStrategy;
@@ -413,7 +413,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = Long.valueOf(RandomStringUtils.randomNumeric(4));
final Long applyLoanRequestId = ThreadLocalRandom.current().nextLong(1000, 10_000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long createChargeRequestId = disburseLoanRequestId + 1;
@@ -474,7 +474,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = Long.valueOf(RandomStringUtils.randomNumeric(4));
final Long applyLoanRequestId = ThreadLocalRandom.current().nextLong(1000, 10_000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long createChargeRequestId = disburseLoanRequestId + 1;
@@ -1671,7 +1671,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
final Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
final LocalDate date = LocalDate.now(Utils.getZoneIdOfTenant());
final Long applyLoanRequestId = Long.valueOf(RandomStringUtils.randomNumeric(4));
final Long applyLoanRequestId = ThreadLocalRandom.current().nextLong(1000, 10_000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long getLoanBeforeTxnRequestId = disburseLoanRequestId + 1;
@@ -2275,7 +2275,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = RandomUtils.nextLong(100, 1000);
final Long applyLoanRequestId = ThreadLocalRandom.current().nextLong(100, 1000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long updateLoanRequestId = disburseLoanRequestId + 1;
@@ -2332,7 +2332,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = RandomUtils.nextLong(100, 1000);
final long applyLoanRequestId = ThreadLocalRandom.current().nextLong(100, 1000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long updateLoanRequestId = disburseLoanRequestId + 1;
@@ -2399,7 +2399,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = RandomUtils.nextLong(100, 1000);
final long applyLoanRequestId = ThreadLocalRandom.current().nextLong(100, 1000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long getLoanRequestId = disburseLoanRequestId + 1;
@@ -2481,7 +2481,7 @@ public class BatchApiTest extends BaseLoanIntegrationTest {
.withInterestTypeAsDecliningBalance() //
.currencyDetails("0", "100").build(null);
final Long applyLoanRequestId = RandomUtils.nextLong(100, 1000);
final Long applyLoanRequestId = ThreadLocalRandom.current().nextLong(100, 1000);
final Long approveLoanRequestId = applyLoanRequestId + 1;
final Long disburseLoanRequestId = approveLoanRequestId + 1;
final Long getLoanRequestId = disburseLoanRequestId + 1;