Skip to content

Commit

Permalink
FINERACT-2070: Update test configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsaghy committed Nov 9, 2024
1 parent 17a4392 commit 64976f1
Show file tree
Hide file tree
Showing 28 changed files with 1,021 additions and 362 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Build the image
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
- name: Start the Fineract stack
run: docker compose -f docker-compose-postgresql.yml up -d
run: docker compose -f docker-compose-postgresql-test-activemq.yml up -d
- name: Wait for stack to come up
run: sleep 400
- name: Check the stack
Expand All @@ -39,5 +39,7 @@ jobs:
TEST_PASSWORD: password
TEST_TENANT_ID: default
INITIALIZATION_ENABLED: true
EVENT_VERIFICATION_ENABLED: false
EVENT_VERIFICATION_ENABLED: true
ACTIVEMQ_BROKER_URL: tcp://localhost:61616
ACTIVEMQ_TOPIC_NAME: events
run: ./gradlew --no-daemon --console=plain fineract-e2e-tests-runner:cucumber --tags 'not @Skip' allureReport
5 changes: 5 additions & 0 deletions config/docker/env/activemq.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
# under the License.
#

FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_ENABLED=true
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_BROKER_URL=tcp://activemq:61616
FINERACT_EXTERNAL_EVENTS_ENABLED=true
FINERACT_EXTERNAL_EVENTS_PRODUCER_JMS_ENABLED=true
FINERACT_EXTERNAL_EVENTS_PRODUCER_JMS_TOPIC_NAME=events
FINERACT_EXTERNAL_EVENTS_PRODUCER_JMS_BROKER_URL=tcp://activemq:61616
2 changes: 1 addition & 1 deletion config/docker/env/fineract-common.env
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ FINERACT_DEFAULT_TENANTDB_PWD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
FINERACT_DEFAULT_MASTER_PASSWORD=fineract
FINERACT_MANAGEMENT_ENDPOINT_WEB_EXPOSURE_INCLUDE=health,info,prometheus
FINERACT_MANAGEMENT_METRICS_TAGS_APPLICATION=fineract
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=true
FINERACT_INSECURE_HTTP_CLIENT=true
SPRING_PROFILES_ACTIVE=test,diagnostics
OTEL_SERVICE_NAME=fineract
Expand Down
1 change: 1 addition & 0 deletions config/docker/env/kafka-client-msk.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#

FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_KAFKA_ENABLED=true
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_KAFKA_BOOTSTRAP_SERVERS=b-3-public.democluster1.am2oyx.c4.kafka.eu-central-1.amazonaws.com:9198,b-2-public.democluster1.am2oyx.c4.kafka.eu-central-1.amazonaws.com:9198,b-1-public.democluster1.am2oyx.c4.kafka.eu-central-1.amazonaws.com:9198
Expand Down
1 change: 1 addition & 0 deletions config/docker/env/kafka-client.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
#

FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_ENABLED=false
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_KAFKA_ENABLED=true
FINERACT_REMOTE_JOB_MESSAGE_HANDLER_KAFKA_BOOTSTRAP_SERVERS=kafka:9092
Expand Down
45 changes: 45 additions & 0 deletions docker-compose-postgresql-test-activemq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.
#

version: "3.8"

services:
activemq:
extends:
file: ./config/docker/compose/activemq.yml
service: activemq

db:
extends:
file: ./config/docker/compose/postgresql.yml
service: postgresql

fineract:
extends:
file: ./config/docker/compose/fineract.yml
service: fineract
ports:
- "8443:8443"
depends_on:
db:
condition: service_healthy
env_file:
- ./config/docker/env/fineract.env
- ./config/docker/env/fineract-common.env
- ./config/docker/env/fineract-postgresql.env
- ./config/docker/env/activemq.env
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ public void initialize() throws Exception {
.name(name48)//
.supportedInterestRefundTypes(Arrays.asList("MERCHANT_ISSUED_REFUND", "PAYOUT_REFUND"))//
.paymentAllocation(List.of(//
createPaymentAllocation("DEFAULT", "LAST_INSTALLMENT")));//
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT")));//
Response<PostLoanProductsResponse> responseLoanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundInterestRecalculation = loanProductsApi
.createLoanProduct(loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundRecalculation).execute();
TestContext.INSTANCE.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public <R, T extends Event<R>> EventAssertionBuilder<R> assertEvent(Class<T> eve
} else {
eventMessage = (EventMessage<R>) new EmptyEventMessage();
}
log.info("Assert event: {}", eventMessage.getIdempotencyKey());
log.debug("Assert event: {}", eventMessage.getIdempotencyKey());
return new EventAssertionBuilder<>(eventMessage);
}

Expand Down Expand Up @@ -167,7 +167,11 @@ public class EventBigDecimalAssertionBuilder<R> {

public EventAssertionBuilder<R> isEqualTo(BigDecimal value) {
if (eventProperties.isEventVerificationEnabled()) {
Assertions.assertThat(extractedValue).isEqualByComparingTo(value);
if (extractedValue == null) {
Assertions.assertThat(extractedValue).isEqualTo(value);
} else {
Assertions.assertThat(extractedValue).isEqualByComparingTo(value);
}
}
return new EventAssertionBuilder<>(eventMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ public void createLoanEventCheck(Response<PostLoansResponse> createLoanResponse)
eventAssertion.assertEvent(LoanCreatedEvent.class, createLoanResponse.body().getLoanId())//
.extractingData(LoanAccountDataV1::getId).isEqualTo(body.getId())//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
.extractingData(LoanAccountDataV1::getClientId).isEqualTo(Long.valueOf(body.getClientId()))//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getPrincipal().longValue())
.isEqualTo(body.getPrincipal().longValue())//
.extractingData(LoanAccountDataV1::getClientId).isEqualTo(body.getClientId())//
.extractingBigDecimal(LoanAccountDataV1::getPrincipal).isEqualTo(body.getPrincipal())//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
.isEqualTo(body.getCurrency().getCode());//
}
Expand All @@ -145,8 +144,7 @@ public void approveLoanEventCheck(Response<PostLoansLoanIdResponse> loanApproveR
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getId()).isEqualTo(body.getStatus().getId())//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getStatus().getCode()).isEqualTo(body.getStatus().getCode())//
.extractingData(LoanAccountDataV1::getClientId).isEqualTo(Long.valueOf(body.getClientId()))//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getApprovedPrincipal().longValue())
.isEqualTo(body.getApprovedPrincipal().longValue())//
.extractingBigDecimal(LoanAccountDataV1::getApprovedPrincipal).isEqualTo(BigDecimal.valueOf(body.getApprovedPrincipal()))//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getTimeline().getApprovedOnDate())//
.isEqualTo(FORMATTER_EVENTS.format(body.getTimeline().getApprovedOnDate()))//
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getCurrency().getCode())
Expand Down Expand Up @@ -239,9 +237,9 @@ private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClaz
}

private boolean areBigDecimalValuesEqual(BigDecimal actual, BigDecimal expected) {
log.info("--- Checking BigDecimal values.... ---");
log.info("Actual: {}", actual);
log.info("Expected: {}", expected);
log.debug("--- Checking BigDecimal values.... ---");
log.debug("Actual: {}", actual);
log.debug("Expected: {}", expected);
return actual.compareTo(expected) == 0;
}

Expand All @@ -261,8 +259,7 @@ public void loanDisbursalTransactionEventCheck(Response<PostLoansLoanIdResponse>
eventAssertion.assertEvent(LoanDisbursalTransactionEvent.class, disbursementTransaction.getId())//
.extractingData(LoanTransactionDataV1::getLoanId).isEqualTo(body.getId())//
.extractingData(LoanTransactionDataV1::getDate).isEqualTo(FORMATTER_EVENTS.format(disbursementTransaction.getDate()))//
.extractingData(loanTransactionDataV1 -> loanTransactionDataV1.getAmount().longValue())
.isEqualTo(disbursementTransaction.getAmount().longValue());//
.extractingBigDecimal(LoanTransactionDataV1::getAmount).isEqualTo(BigDecimal.valueOf(disbursementTransaction.getAmount()));//
}

public EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> transactionEventCheck(
Expand Down Expand Up @@ -291,8 +288,7 @@ public EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> transactionEv
EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> eventBuilder = eventAssertion.assertEvent(eventClass, transactionId);
eventBuilder.extractingData(LoanTransactionDataV1::getLoanId).isEqualTo(loanDetailsResponse.body().getId())//
.extractingData(LoanTransactionDataV1::getDate).isEqualTo(FORMATTER_EVENTS.format(transactionFound.getDate()))//
.extractingData(loanTransactionDataV1 -> loanTransactionDataV1.getAmount().longValue())
.isEqualTo(transactionFound.getAmount().longValue())//
.extractingBigDecimal(LoanTransactionDataV1::getAmount).isEqualTo(BigDecimal.valueOf(transactionFound.getAmount()))//
.extractingData(LoanTransactionDataV1::getExternalOwnerId).isEqualTo(externalOwnerId);//
return eventBuilder;
}
Expand All @@ -316,13 +312,15 @@ public void loanOwnershipTransferBusinessEventCheck(Long loanId, Long transferId
.isEqualTo(filtered.getOwner().getExternalId()).extractingData(LoanOwnershipTransferDataV1::getTransferExternalId)
.isEqualTo(filtered.getTransferExternalId()).extractingData(LoanOwnershipTransferDataV1::getSettlementDate)
.isEqualTo(FORMATTER_EVENTS.format(filtered.getSettlementDate()))
.extractingData(LoanOwnershipTransferDataV1::getTotalOutstandingBalanceAmount)
.extractingBigDecimal(LoanOwnershipTransferDataV1::getTotalOutstandingBalanceAmount)
.isEqualTo(totalOutstandingBalanceAmountExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingPrincipalPortion).isEqualTo(outstandingPrincipalPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingFeePortion).isEqualTo(outstandingFeePortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingPenaltyPortion).isEqualTo(outstandingPenaltyPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingInterestPortion).isEqualTo(outstandingInterestPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOverPaymentPortion).isEqualTo(overPaymentPortionExpected);
.extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingPrincipalPortion)
.isEqualTo(outstandingPrincipalPortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingFeePortion)
.isEqualTo(outstandingFeePortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingPenaltyPortion)
.isEqualTo(outstandingPenaltyPortionExpected)
.extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingInterestPortion)
.isEqualTo(outstandingInterestPortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOverPaymentPortion)
.isEqualTo(overPaymentPortionExpected);
}

public void loanOwnershipTransferBusinessEventWithStatusCheck(Long loanId, Long transferId, String transferStatus,
Expand Down Expand Up @@ -358,15 +356,17 @@ public void loanOwnershipTransferBusinessEventWithStatusCheck(Long loanId, Long
.isEqualTo(filtered.getOwner().getExternalId()).extractingData(LoanOwnershipTransferDataV1::getTransferExternalId)
.isEqualTo(filtered.getTransferExternalId()).extractingData(LoanOwnershipTransferDataV1::getSettlementDate)
.isEqualTo(FORMATTER_EVENTS.format(filtered.getSettlementDate()))
.extractingData(LoanOwnershipTransferDataV1::getTotalOutstandingBalanceAmount)
.extractingBigDecimal(LoanOwnershipTransferDataV1::getTotalOutstandingBalanceAmount)
.isEqualTo(totalOutstandingBalanceAmountExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingPrincipalPortion).isEqualTo(outstandingPrincipalPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingFeePortion).isEqualTo(outstandingFeePortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingPenaltyPortion).isEqualTo(outstandingPenaltyPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOutstandingInterestPortion).isEqualTo(outstandingInterestPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getOverPaymentPortion).isEqualTo(overPaymentPortionExpected)
.extractingData(LoanOwnershipTransferDataV1::getTransferStatus).isEqualTo(transferStatusExpected)
.extractingData(LoanOwnershipTransferDataV1::getTransferStatusReason).isEqualTo(transferStatusReasonExpected);
.extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingPrincipalPortion)
.isEqualTo(outstandingPrincipalPortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingFeePortion)
.isEqualTo(outstandingFeePortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingPenaltyPortion)
.isEqualTo(outstandingPenaltyPortionExpected)
.extractingBigDecimal(LoanOwnershipTransferDataV1::getOutstandingInterestPortion)
.isEqualTo(outstandingInterestPortionExpected).extractingBigDecimal(LoanOwnershipTransferDataV1::getOverPaymentPortion)
.isEqualTo(overPaymentPortionExpected).extractingData(LoanOwnershipTransferDataV1::getTransferStatus)
.isEqualTo(transferStatusExpected).extractingData(LoanOwnershipTransferDataV1::getTransferStatusReason)
.isEqualTo(transferStatusReasonExpected);
}

public void loanAccountSnapshotBusinessEventCheck(Long loanId, Long transferId) throws IOException {
Expand All @@ -389,17 +389,17 @@ public void loanAccountSnapshotBusinessEventCheck(Long loanId, Long transferId)
eventAssertion.assertEvent(LoanAccountSnapshotEvent.class, loanId).extractingData(LoanAccountDataV1::getId).isEqualTo(loanId)
.extractingData(LoanAccountDataV1::getExternalOwnerId).isEqualTo(ownerExternalIdExpected)
.extractingData(LoanAccountDataV1::getSettlementDate).isEqualTo(settlementDateExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getTotalOutstanding())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getTotalOutstanding())
.isEqualTo(totalOutstandingBalanceAmountExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getPrincipalOutstanding())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getPrincipalOutstanding())
.isEqualTo(outstandingPrincipalPortionExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getFeeChargesOutstanding())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getFeeChargesOutstanding())
.isEqualTo(outstandingFeePortionExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getPenaltyChargesOutstanding())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getPenaltyChargesOutstanding())
.isEqualTo(outstandingPenaltyPortionExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getInterestOutstanding())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getInterestOutstanding())
.isEqualTo(outstandingInterestPortionExpected)
.extractingData(loanAccountDataV1 -> loanAccountDataV1.getSummary().getTotalOverdue())
.extractingBigDecimal(loanAccountDataV1 -> loanAccountDataV1.getSummary().getTotalOverdue())
.isEqualTo(overPaymentPortionExpected);
}

Expand Down Expand Up @@ -435,15 +435,15 @@ public void loanAccountDelinquencyPauseChangedBusinessEventCheck(Long loanId) th
pausePeriodEndExpected))//
.isEqualTo(pausePeriodEndExpected);//

log.info("LoanAccountDelinquencyPauseChangedBusinessEvent -> isActiveActual:\s{}", isActiveActual);
log.info("LoanAccountDelinquencyPauseChangedBusinessEvent -> pausePeriodStartActual:\s{}", pausePeriodStartActual);
log.info("LoanAccountDelinquencyPauseChangedBusinessEvent -> pausePeriodEndActual:\s{}", pausePeriodEndActual);
log.debug("LoanAccountDelinquencyPauseChangedBusinessEvent -> isActiveActual:\s{}", isActiveActual);
log.debug("LoanAccountDelinquencyPauseChangedBusinessEvent -> pausePeriodStartActual:\s{}", pausePeriodStartActual);
log.debug("LoanAccountDelinquencyPauseChangedBusinessEvent -> pausePeriodEndActual:\s{}", pausePeriodEndActual);
}
return null;
});
}

public void installmentLevelDelinquencyRangeChangeEventCheck(Long loanId) throws IOException {
public void installmentLevelDelinquencyRangeChangeEventCheck(Long loanId) {
eventAssertion.assertEvent(LoanDelinquencyRangeChangeEvent.class, loanId).extractingData(loanAccountDelinquencyRangeDataV1 -> {
// check if sum of total amounts equal the sum of amount types in installmentDelinquencyBuckets
BigDecimal totalAmountSum = loanAccountDelinquencyRangeDataV1.getInstallmentDelinquencyBuckets().stream()//
Expand Down Expand Up @@ -471,13 +471,13 @@ public void installmentLevelDelinquencyRangeChangeEventCheck(Long loanId) throws

assertThat(totalAmountSum)
.as(ErrorMessageHelper.wrongAmountInLoanDelinquencyRangeChangedEventTotalAmount(totalAmountSum, totalAmountSumActual))
.isEqualTo(totalAmountSumActual);
.isEqualByComparingTo(totalAmountSumActual);

log.info("Nr of installment level delinquency buckets: {}",
log.debug("Nr of installment level delinquency buckets: {}",
loanAccountDelinquencyRangeDataV1.getInstallmentDelinquencyBuckets().size());
log.info("Buckets:");
log.debug("Buckets:");
loanAccountDelinquencyRangeDataV1.getInstallmentDelinquencyBuckets().forEach(e -> {
log.info("{}\s-\sTotal amount:\s{}", e.getDelinquencyRange().getClassification(), e.getAmount().getTotalAmount());
log.debug("{}\s-\sTotal amount:\s{}", e.getDelinquencyRange().getClassification(), e.getAmount().getTotalAmount());
});

return null;
Expand Down
Loading

0 comments on commit 64976f1

Please sign in to comment.