Skip to content

Commit f28382b

Browse files
committed
FINERACT-2380: move retrofit client based test to feign
1 parent 5d2a9c5 commit f28382b

22 files changed

Lines changed: 98 additions & 158 deletions

File tree

fineract-client-feign/src/main/java/org/apache/fineract/client/feign/BasicAuthRequestInterceptor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public BasicAuthRequestInterceptor(String username, String password) {
5151

5252
@Override
5353
public void apply(RequestTemplate template) {
54-
template.header(AUTHORIZATION_HEADER, BASIC_AUTH_PREFIX + credentials);
54+
if (!template.headers().containsKey(AUTHORIZATION_HEADER)) {
55+
template.header(AUTHORIZATION_HEADER, BASIC_AUTH_PREFIX + credentials);
56+
}
5557
}
5658
}

fineract-client-feign/src/main/java/org/apache/fineract/client/feign/FineractFeignClient.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import org.apache.fineract.client.feign.services.EntityFieldConfigurationApi;
6262
import org.apache.fineract.client.feign.services.ExternalAssetOwnerLoanProductAttributesApi;
6363
import org.apache.fineract.client.feign.services.ExternalAssetOwnersApi;
64-
import org.apache.fineract.client.feign.services.ExternalAssetOwnersApiExtension;
6564
import org.apache.fineract.client.feign.services.ExternalEventConfigurationApi;
6665
import org.apache.fineract.client.feign.services.ExternalServicesApi;
6766
import org.apache.fineract.client.feign.services.FetchAuthenticatedUserDetailsApi;
@@ -96,7 +95,6 @@
9695
import org.apache.fineract.client.feign.services.LoanCollateralApi;
9796
import org.apache.fineract.client.feign.services.LoanCollateralManagementApi;
9897
import org.apache.fineract.client.feign.services.LoanDisbursementDetailsApi;
99-
import org.apache.fineract.client.feign.services.LoanDisbursementDetailsApiExtension;
10098
import org.apache.fineract.client.feign.services.LoanInterestPauseApi;
10199
import org.apache.fineract.client.feign.services.LoanProductsApi;
102100
import org.apache.fineract.client.feign.services.LoanReschedulingApi;
@@ -394,10 +392,6 @@ public ExternalAssetOwnersApi externalAssetOwners() {
394392
return create(ExternalAssetOwnersApi.class);
395393
}
396394

397-
public ExternalAssetOwnersApiExtension externalAssetOwnersExtension() {
398-
return create(ExternalAssetOwnersApiExtension.class);
399-
}
400-
401395
public ExternalEventConfigurationApi externalEventConfiguration() {
402396
return create(ExternalEventConfigurationApi.class);
403397
}
@@ -534,10 +528,6 @@ public LoanDisbursementDetailsApi loanDisbursementDetails() {
534528
return create(LoanDisbursementDetailsApi.class);
535529
}
536530

537-
public LoanDisbursementDetailsApiExtension loanDisbursementDetailsExtension() {
538-
return create(LoanDisbursementDetailsApiExtension.class);
539-
}
540-
541531
public LoanInterestPauseApi loanInterestPause() {
542532
return create(LoanInterestPauseApi.class);
543533
}

fineract-client-feign/src/main/java/org/apache/fineract/client/feign/services/ExternalAssetOwnersApiExtension.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/LoanProductResolver.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ public long resolve(LoanProduct loanProduct) {
4040
log.debug("Resolving loan product by name [{}]", loanProductName);
4141
List<GetLoanProductsResponse> loanProductsResponses = ok(() -> fineractClient.loanProducts().retrieveAllLoanProducts(Map.of()));
4242

43-
log.info("Retrieved {} loan products from API", loanProductsResponses.size());
44-
log.info("Available loan products: {}", loanProductsResponses.stream().map(GetLoanProductsResponse::getName).toList());
45-
4643
GetLoanProductsResponse foundLpr = loanProductsResponses.stream().filter(lpr -> loanProductName.equals(lpr.getName())).findAny()
4744
.orElseThrow(() -> new IllegalArgumentException("Loan product [%s] not found".formatted(loanProductName)));
4845
return foundLpr.getId();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/base/FineractInitializer.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ public class FineractInitializer implements InitializingBean {
4141

4242
@Override
4343
public void afterPropertiesSet() throws Exception {
44-
// ALWAYS log initializer counts at INFO level for debugging
45-
log.info("=== FineractInitializer.afterPropertiesSet() called ===");
46-
log.info("Global initializers count: {}", globalInitializerSteps.size());
47-
log.info("Suite initializers count: {}", suiteInitializerSteps.size());
48-
log.info("Scenario initializers count: {}", scenarioInitializerSteps.size());
44+
log.debug("=== FineractInitializer.afterPropertiesSet() called ===");
45+
log.debug("Global initializers count: {}", globalInitializerSteps.size());
46+
log.debug("Suite initializers count: {}", suiteInitializerSteps.size());
47+
log.debug("Scenario initializers count: {}", scenarioInitializerSteps.size());
4948

5049
if (log.isDebugEnabled()) {
5150
String globalInitializers = globalInitializerSteps.stream().map(Object::getClass).map(Class::getName)
@@ -64,7 +63,7 @@ public void afterPropertiesSet() throws Exception {
6463
// Always log the suite initializers at INFO since this is critical
6564
String suiteInitializers = suiteInitializerSteps.stream().map(Object::getClass).map(Class::getName)
6665
.collect(Collectors.joining(", "));
67-
log.info("Suite initializers: [{}]", suiteInitializers);
66+
log.debug("Suite initializers: [{}]", suiteInitializers);
6867
}
6968
}
7069

@@ -76,9 +75,9 @@ public void setupGlobalDefaults() throws Exception {
7675
}
7776

7877
public void setupDefaultsForSuite() throws Exception {
79-
log.info("=== setupDefaultsForSuite() called - {} suite initializers to execute ===", suiteInitializerSteps.size());
78+
log.debug("=== setupDefaultsForSuite() called - {} suite initializers to execute ===", suiteInitializerSteps.size());
8079
for (FineractSuiteInitializerStep initializerStep : suiteInitializerSteps) {
81-
log.info("Executing suite initializer: {}", initializerStep.getClass().getName());
80+
log.debug("Executing suite initializer: {}", initializerStep.getClass().getName());
8281
initializerStep.initializeForSuite();
8382
}
8483
businessDateHelper.setBusinessDateToday();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/CodeGlobalInitializerStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public void createCodeValues(Long codeId, List<String> codeValueNames) {
271271

272272
try {
273273
executeVoid(() -> fineractClient.codeValues().createCodeValue(codeId, postCodeValuesDataRequest, Map.of()));
274-
log.info("Code value '{}' created successfully", name);
274+
log.debug("Code value '{}' created successfully", name);
275275
} catch (CallFailedRuntimeException e) {
276276
if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
277277
log.debug("Code value '{}' already exists, skipping creation", name);

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/FinancialActivityMappingGlobalInitializerStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void initialize() {
4545

4646
try {
4747
executeVoid(() -> fineractClient.mappingFinancialActivitiesToAccounts().createGLAccount(request, Map.of()));
48-
log.info("Financial activity mapping created successfully");
48+
log.debug("Financial activity mapping created successfully");
4949
} catch (CallFailedRuntimeException e) {
5050
if (e.getStatus() == 403 && e.getDeveloperMessage() != null && e.getDeveloperMessage().contains("already exists")) {
5151
log.debug("Financial activity mapping already exists, skipping creation");

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,14 +4329,14 @@ private static List<PaymentAllocationOrder> getPaymentAllocationOrder(
43294329

43304330
private PostLoanProductsResponse createLoanProductIdempotent(PostLoanProductsRequest loanProductRequest) {
43314331
String productName = loanProductRequest.getName();
4332-
log.info("Attempting to create loan product: {}", productName);
4332+
log.debug("Attempting to create loan product: {}", productName);
43334333
try {
43344334
List<GetLoanProductsResponse> existingProducts = fineractClient.loanProducts().retrieveAllLoanProducts(Map.of());
43354335
GetLoanProductsResponse existingProduct = existingProducts.stream().filter(p -> productName.equals(p.getName())).findFirst()
43364336
.orElse(null);
43374337

43384338
if (existingProduct != null) {
4339-
log.info("Loan product '{}' already exists with ID: {}", productName, existingProduct.getId());
4339+
log.debug("Loan product '{}' already exists with ID: {}", productName, existingProduct.getId());
43404340
PostLoanProductsResponse response = new PostLoanProductsResponse();
43414341
response.setResourceId(existingProduct.getId());
43424342
return response;
@@ -4345,10 +4345,10 @@ private PostLoanProductsResponse createLoanProductIdempotent(PostLoanProductsReq
43454345
log.warn("Error checking if loan product '{}' exists", productName, e);
43464346
}
43474347

4348-
log.info("Creating new loan product: {}", productName);
4348+
log.debug("Creating new loan product: {}", productName);
43494349
try {
43504350
PostLoanProductsResponse response = ok(() -> fineractClient.loanProducts().createLoanProduct(loanProductRequest, Map.of()));
4351-
log.info("Successfully created loan product '{}' with ID: {}", productName, response.getResourceId());
4351+
log.debug("Successfully created loan product '{}' with ID: {}", productName, response.getResourceId());
43524352
return response;
43534353
} catch (Exception e) {
43544354
log.error("FAILED to create loan product '{}'", productName, e);

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/ExternalEventSuiteInitializerStep.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ExternalEventSuiteInitializerStep implements FineractSuiteInitializ
5555

5656
@Override
5757
public void initializeForSuite() throws InterruptedException {
58-
log.info("=== ExternalEventSuiteInitializerStep.initializeForSuite() - START ===");
58+
log.debug("=== ExternalEventSuiteInitializerStep.initializeForSuite() - START ===");
5959

6060
// Step 1: Enable all external events
6161
Map<String, Boolean> eventConfigMap = new HashMap<>();
@@ -72,7 +72,7 @@ public void initializeForSuite() throws InterruptedException {
7272
.externalEventConfigurations(eventConfigMap);
7373

7474
executeVoid(() -> fineractClient.externalEventConfiguration().updateExternalEventConfigurations(null, request, Map.of()));
75-
log.info("=== External event configuration updated - all events enabled ===");
75+
log.debug("=== External event configuration updated - all events enabled ===");
7676

7777
// Step 2: Wait for JMS Listener to be ready before proceeding
7878
if (eventProperties != null && eventProperties.isEventVerificationEnabled()) {
@@ -93,6 +93,6 @@ public void initializeForSuite() throws InterruptedException {
9393
}
9494
}
9595

96-
log.info("=== ExternalEventSuiteInitializerStep.initializeForSuite() - COMPLETED ===");
96+
log.debug("=== ExternalEventSuiteInitializerStep.initializeForSuite() - COMPLETED ===");
9797
}
9898
}

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/suite/JobSuiteInitializerStep.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,44 +40,44 @@ public class JobSuiteInitializerStep implements FineractSuiteInitializerStep {
4040
private final FineractFeignClient fineractClient;
4141

4242
public JobSuiteInitializerStep(FineractFeignClient fineractClient) {
43-
log.info("=== JobSuiteInitializerStep: Constructor called - bean is being created ===");
43+
log.debug("=== JobSuiteInitializerStep: Constructor called - bean is being created ===");
4444
this.fineractClient = fineractClient;
45-
log.info("=== JobSuiteInitializerStep: FineractFeignClient injected successfully ===");
45+
log.debug("=== JobSuiteInitializerStep: FineractFeignClient injected successfully ===");
4646
}
4747

4848
@Override
4949
public void initializeForSuite() throws InterruptedException {
50-
log.info("=== JobSuiteInitializerStep.initializeForSuite() - START ===");
50+
log.debug("=== JobSuiteInitializerStep.initializeForSuite() - START ===");
5151
enableAndExecuteEventJob();
52-
log.info("=== JobSuiteInitializerStep.initializeForSuite() - COMPLETED successfully ===");
52+
log.debug("=== JobSuiteInitializerStep.initializeForSuite() - COMPLETED successfully ===");
5353
}
5454

5555
private void enableAndExecuteEventJob() throws InterruptedException {
56-
log.info("=== Initializing Send Asynchronous Events job ===");
56+
log.debug("=== Initializing Send Asynchronous Events job ===");
5757
Long jobId = updateExternalEventJobFrequency(EVERY_1_SECONDS);
58-
log.info("=== Updated cron expression to EVERY_1_SECONDS ===");
58+
log.debug("=== Updated cron expression to EVERY_1_SECONDS ===");
5959

6060
// CRITICAL: SchedulerGlobalInitializerStep stops the scheduler globally
6161
// Solution: START the scheduler so the job runs every 1 second automatically
62-
log.info("Starting scheduler to enable automatic job execution every 1 second...");
62+
log.debug("Starting scheduler to enable automatic job execution every 1 second...");
6363
executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus("start", Map.of()));
64-
log.info("Scheduler started successfully");
64+
log.debug("Scheduler started successfully");
6565

6666
// Manually execute once immediately to publish any queued events from initialization
67-
log.info("Manually executing '{}' job once to publish queued events...", SEND_ASYNCHRONOUS_EVENTS_JOB_NAME);
67+
log.debug("Manually executing '{}' job once to publish queued events...", SEND_ASYNCHRONOUS_EVENTS_JOB_NAME);
6868
executeVoid(() -> fineractClient.schedulerJob().executeJob(jobId, new ExecuteJobRequest(), Map.of("command", "executeJob")));
6969

7070
// Poll job history to confirm it ran
71-
log.info("Polling job history to confirm initial execution...");
71+
log.debug("Polling job history to confirm initial execution...");
7272
Long initialRunCount = getJobRunCount(jobId);
73-
log.info("Initial job run count: {}", initialRunCount);
73+
log.debug("Initial job run count: {}", initialRunCount);
7474

7575
boolean jobRan = false;
7676
for (int i = 0; i < 30; i++) {
7777
Thread.sleep(200);
7878
Long currentRunCount = getJobRunCount(jobId);
7979
if (currentRunCount > initialRunCount) {
80-
log.info("Job execution confirmed! Run count increased from {} to {}", initialRunCount, currentRunCount);
80+
log.debug("Job execution confirmed! Run count increased from {} to {}", initialRunCount, currentRunCount);
8181
jobRan = true;
8282
break;
8383
}
@@ -88,9 +88,9 @@ private void enableAndExecuteEventJob() throws InterruptedException {
8888
}
8989

9090
// Wait for events to propagate to ActiveMQ
91-
log.info("Waiting 1 second for event propagation to ActiveMQ...");
91+
log.debug("Waiting 1 second for event propagation to ActiveMQ...");
9292
Thread.sleep(1000);
93-
log.info("Scheduler is now running - job will execute every 1 second automatically");
93+
log.debug("Scheduler is now running - job will execute every 1 second automatically");
9494
}
9595

9696
private Long getJobRunCount(Long jobId) {
@@ -105,20 +105,20 @@ private Long getJobRunCount(Long jobId) {
105105

106106
@Override
107107
public void resetAfterSuite() {
108-
log.info("=== JobSuiteInitializerStep.resetAfterSuite() - START ===");
108+
log.debug("=== JobSuiteInitializerStep.resetAfterSuite() - START ===");
109109

110110
// Stop the scheduler to prevent jobs from running between test suites
111-
log.info("Stopping scheduler...");
111+
log.debug("Stopping scheduler...");
112112
try {
113113
executeVoid(() -> fineractClient.scheduler().changeSchedulerStatus(Map.of("command", "stop")));
114-
log.info("Scheduler stopped successfully");
114+
log.debug("Scheduler stopped successfully");
115115
} catch (Exception e) {
116116
log.warn("Failed to stop scheduler: {}", e.getMessage());
117117
}
118118

119119
// Reset cron expression to default
120120
updateExternalEventJobFrequency(EVERY_60_SECONDS);
121-
log.info("=== JobSuiteInitializerStep.resetAfterSuite() - COMPLETED ===");
121+
log.debug("=== JobSuiteInitializerStep.resetAfterSuite() - COMPLETED ===");
122122
}
123123

124124
private Long updateExternalEventJobFrequency(String cronExpression) {

0 commit comments

Comments
 (0)