Skip to content

Commit 58ada94

Browse files
committed
FINERACT-2541: added e2e test for validation of owner to owner transfer functionality
1 parent babe420 commit 58ada94

File tree

12 files changed

+300
-78
lines changed

12 files changed

+300
-78
lines changed

config/docker/compose/activemq.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ services:
2424
ports:
2525
- "6161:6161"
2626
- "61616:61616"
27+
- "8161:8161"

config/docker/compose/fineract.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# under the License.
1717
#
1818

19+
version: "3.8"
20+
1921
services:
2022
fineract:
2123
image: fineract:latest
@@ -24,7 +26,6 @@ services:
2426
- ${PWD}/config/docker/logback/logback-override.xml:/app/logback-override.xml
2527
- ${PWD}/config/docker/aws/etc/credentials:/etc/aws/credentials:ro
2628
- ${PWD}/build/fineract/logs:/var/logs/fineract:rw
27-
# - ${PWD}/build/fineract/tmp:/tmp:rw
2829
healthcheck:
2930
test: ["CMD", 'sh', '-c', 'echo -e "Checking for the availability of Fineract server deployment"; while ! nc -z "localhost" 8443; do sleep 1; printf "-"; done; echo -e " >> Fineract server has started";' ]
3031
timeout: 1s

config/docker/env/fineract-common.env

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#
1919

2020
# ... following variables are optional; "application.properties" contains reasonable defaults (same as here)
21-
FINERACT_USER=1000
22-
FINERACT_GROUP=1000
21+
FINERACT_USER=rzeinalov
22+
FINERACT_GROUP=staff
2323
FINERACT_HIKARI_MINIMUM_IDLE=3
2424
FINERACT_HIKARI_MAXIMUM_POOL_SIZE=10
2525
FINERACT_HIKARI_IDLE_TIMEOUT=60000
@@ -50,6 +50,7 @@ FINERACT_DEFAULT_TENANTDB_DESCRIPTION=Default Demo Tenant
5050
FINERACT_DEFAULT_TENANTDB_HOSTNAME=db
5151
FINERACT_DEFAULT_TENANTDB_PWD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
5252
FINERACT_DEFAULT_MASTER_PASSWORD=fineract
53+
FINERACT_MODULE_LOAN_ORIGINATION_ENABLED=true
5354
FINERACT_MANAGEMENT_ENDPOINT_WEB_EXPOSURE_INCLUDE=health,info,prometheus
5455
FINERACT_MANAGEMENT_METRICS_TAGS_APPLICATION=fineract
5556
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=true

docker-compose-postgresql-activemq.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ services:
5050
service: fineract
5151
deploy:
5252
mode: replicated
53-
replicas: 2
53+
replicas: 1
5454
ports:
5555
- "8444-8445:8443"
5656
depends_on:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public enum AssetExternalizationErrorMessage {
3131
LOAN_CLOSED_OBLIGATIONS_MET_INVALID("Loan status CLOSED_OBLIGATIONS_MET is not valid for transfer."), //
3232
LOAN_SUBMITTED_AND_PENDING_APPROVAL_INVALID("Loan status SUBMITTED_AND_PENDING_APPROVAL is not valid for transfer."), //
3333
LOAN_APPROVED_INVALID("Loan status APPROVED is not valid for transfer."), //
34+
ALREADY_IN_PROGRESS("This loan cannot be sold, there is already an in progress transfer"), //
3435
INVALID_REQUEST("The request was invalid. This typically will happen due to validation errors which are provided."); //
3536

3637
public final String value;

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ public void loanStatusChangedEventCheck(Long loanId) {
166166
}
167167

168168
private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClazz, Long loanId) {
169-
GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanId,
170-
Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
171-
172169
eventAssertion.assertEvent(eventClazz, loanId)//
173170
.extractingData(loanAccountDataV1 -> {
171+
// Query API after event arrives to ensure both snapshots reflect the same settled state
172+
GetLoansLoanIdResponse body = ok(() -> fineractClient.loans().retrieveLoan(loanId,
173+
Map.of("staffInSelectedOfficeOnly", false, "associations", "all", "exclude", "", "fields", "")));
174174
Long idActual = loanAccountDataV1.getId();
175175
Long idExpected = body.getId();
176176
Long statusIdActual = loanAccountDataV1.getStatus().getId().longValue();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/assetexternalization/AssetExternalizationStepDef.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ private void createAssetExternalizationRequestByLoanId(DataTable table, String t
159159
} else if ((transferData.get(0).equals(TRANSACTION_TYPE_SALE) || transferData.get(0).equals(TRANSACTION_TYPE_INTERMEDIARY_SALE))) {
160160
String ownerExternalId;
161161
if (regenerateOwner) {
162+
// For owner-to-owner transfers: preserve the current owner as previous owner
163+
String currentOwner = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
164+
if (currentOwner != null && !transferData.get(0).equals(TRANSACTION_TYPE_INTERMEDIARY_SALE)) {
165+
testContext().set(TestContextKey.ASSET_EXTERNALIZATION_PREVIOUS_OWNER_EXTERNAL_ID, currentOwner);
166+
}
162167
ownerExternalId = Utils.randomStringGenerator(OWNER_EXTERNAL_ID_PREFIX, 10);
163168
} else {
164169
ownerExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_OWNER_EXTERNAL_ID);
@@ -369,13 +374,20 @@ private void checkExternalAssetDetails(Long loanId, String loanExternalId, PageE
369374
previousAssetOwner = null;
370375
transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
371376
}
372-
} else { // in case transfer has previous intermediarySale transfer
377+
} else { // in case transfer has previous intermediarySale or owner-to-owner transfer
373378
if (transactionType.equalsIgnoreCase(TRANSACTION_TYPE_SALE)
374379
&& (status.equals(ExternalTransferData.StatusEnum.ACTIVE.getValue())
375380
|| status.equals(ExternalTransferData.StatusEnum.PENDING.getValue()))) {
376381
ownerExternalId = ownerExternalIdStored;
377382
previousAssetOwner = intermediarySaleAssetOwner;
378383
transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
384+
} else if (transactionType.equalsIgnoreCase(TRANSACTION_TYPE_SALE)
385+
&& (status.equals(ExternalTransferData.StatusEnum.DECLINED.getValue())
386+
|| status.equals(ExternalTransferData.StatusEnum.CANCELLED.getValue()))) {
387+
// DECLINED and CANCELLED records have previousOwner = null in the API response
388+
ownerExternalId = ownerExternalIdStored;
389+
previousAssetOwner = null;
390+
transferExternalId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_SALES_TRANSFER_EXTERNAL_ID_FROM_RESPONSE);
379391
} else if (transactionType.equalsIgnoreCase(TRANSACTION_TYPE_BUYBACK)
380392
&& (status.equals(ExternalTransferData.StatusEnum.BUYBACK.getValue())
381393
|| status.equals(ExternalTransferData.StatusEnum.BUYBACK_INTERMEDIATE.getValue()))) {

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanRepaymentStepDef.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ public void makeLoanRepaymentAndCheckOwner(String repaymentType, String transact
104104
makeRepayment(repaymentType, transactionDate, transactionAmount, transferExternalOwnerId);
105105
}
106106

107+
@And("Customer makes {string} repayment on {string} with {double} EUR transaction amount and check previous external owner")
108+
public void makeLoanRepaymentAndCheckPreviousOwner(String repaymentType, String transactionDate, double transactionAmount)
109+
throws IOException {
110+
String previousOwnerId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_PREVIOUS_OWNER_EXTERNAL_ID);
111+
makeRepayment(repaymentType, transactionDate, transactionAmount, previousOwnerId);
112+
}
113+
107114
private void makeRepayment(String repaymentType, String transactionDate, double transactionAmount, String transferExternalOwnerId)
108115
throws IOException {
109116
eventStore.reset();

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,14 @@ public void createTransactionWithAutoIdempotencyKeyWithExternalOwner(String tran
389389
transactionAmount, transferExternalOwnerId);
390390
}
391391

392+
@When("Customer makes {string} transaction with {string} payment type on {string} with {double} EUR transaction amount and system-generated Idempotency key and check previous external owner")
393+
public void createTransactionWithAutoIdempotencyKeyWithPreviousExternalOwner(String transactionTypeInput, String transactionPaymentType,
394+
String transactionDate, double transactionAmount) throws IOException {
395+
String previousOwnerId = testContext().get(TestContextKey.ASSET_EXTERNALIZATION_PREVIOUS_OWNER_EXTERNAL_ID);
396+
createTransactionWithAutoIdempotencyKeyAndWithExternalOwner(transactionTypeInput, transactionPaymentType, transactionDate,
397+
transactionAmount, previousOwnerId);
398+
}
399+
392400
@When("Customer makes {string} transaction with {string} payment type on {string} with {double} EUR transaction amount and system-generated Idempotency key and interestRefundCalculation {booleanValue}")
393401
public void createTransactionWithAutoIdempotencyKeyAndWithInterestRefundCalculationFlagProvided(final String transactionTypeInput,
394402
final String transactionPaymentType, final String transactionDate, final double transactionAmount,
@@ -5133,6 +5141,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String transacti
51335141

51345142
testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
51355143
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
5144+
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
51365145
}
51375146

51385147
@And("Admin adds capitalized income adjustment of capitalized income transaction made on {string} with {string} payment type to the loan on {string} with {string} EUR transaction amount")
@@ -5165,6 +5174,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String originalT
51655174
testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
51665175
assert adjustmentResponse != null;
51675176
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
5177+
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
51685178
}
51695179

51705180
@Then("Loan's available disbursement amount is {string}")
@@ -5201,6 +5211,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoanWithCapitalizedIncomeDa
52015211

52025212
testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
52035213
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
5214+
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
52045215
}
52055216

52065217
@And("Admin adds invalid capitalized income adjustment with {string} payment type to the loan on {string} with {string} EUR transaction amount")

fineract-e2e-tests-core/src/test/resources/fineract-test-application.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ fineract-test.api.password=${TEST_PASSWORD:password}
2323
fineract-test.api.strong-password=${TEST_STRONG_PASSWORD:A1b2c3d4e5f$}
2424
fineract-test.api.tenant-id=${TEST_TENANT_ID:default}
2525

26-
fineract-test.initialization.enabled=${INITIALIZATION_ENABLED:false}
26+
fineract-test.initialization.enabled=${INITIALIZATION_ENABLED:true}
2727

2828
fineract-test.testrail.enabled=${TESTRAIL_ENABLED:false}
2929
fineract-test.testrail.base-url=${TESTRAIL_BASEURL:}
3030
fineract-test.testrail.username=${TESTRAIL_USERNAME:}
3131
fineract-test.testrail.password=${TESTRAIL_PASSWORD:}
3232
fineract-test.testrail.run-id=${TESTRAIL_RUN_ID:0}
3333

34-
fineract-test.messaging.jms.broker-url=${ACTIVEMQ_BROKER_URL:}
35-
fineract-test.messaging.jms.broker-username=${ACTIVEMQ_BROKER_USERNAME:}
36-
fineract-test.messaging.jms.broker-password=${ACTIVEMQ_BROKER_PASSWORD:}
37-
fineract-test.messaging.jms.topic-name=${ACTIVEMQ_TOPIC_NAME:}
34+
fineract-test.messaging.jms.broker-url=${ACTIVEMQ_BROKER_URL:tcp://localhost:61616}
35+
fineract-test.messaging.jms.broker-username=${ACTIVEMQ_BROKER_USERNAME:admin}
36+
fineract-test.messaging.jms.broker-password=${ACTIVEMQ_BROKER_PASSWORD:admin}
37+
fineract-test.messaging.jms.topic-name=${ACTIVEMQ_TOPIC_NAME:events}
3838

39-
fineract-test.event.verification-enabled=${EVENT_VERIFICATION_ENABLED:false}
39+
fineract-test.event.verification-enabled=${EVENT_VERIFICATION_ENABLED:true}
4040
fineract-test.event.wait-timeout-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:5000}
4141
fineract-test.event.delay-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:100}
4242
fineract-test.event.interval-in-ms=${POLLING_EVENT_WAIT_TIMEOUT_IN_MS:100}

0 commit comments

Comments
 (0)