Skip to content

Commit 02f5530

Browse files
ruzeynalovmariiaKraievska
authored andcommitted
FINERACT-2455: Added e2e tests for WC - Transaction Type - CBR
1 parent ea32418 commit 02f5530

6 files changed

Lines changed: 709 additions & 2 deletions

File tree

fineract-e2e-tests-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ dependencies {
7171
testImplementation 'io.github.openfeign:feign-core:13.6'
7272
testImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
7373
testImplementation 'org.apache.commons:commons-lang3:3.18.0'
74+
testImplementation 'com.google.guava:guava'
7475
testImplementation ('com.googlecode.json-simple:json-simple:1.1.1') {
7576
exclude group: 'junit', module: 'junit'
7677
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionMerchantIssuedRefundPostEvent;
8484
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionPayoutRefundPostEvent;
8585
import org.apache.fineract.test.messaging.event.loan.transaction.LoanUndoContractTerminationBusinessEvent;
86+
import org.apache.fineract.test.messaging.event.workingcapitalloan.transaction.WorkingCapitalLoanCreditBalanceRefundTransactionBusinessEvent;
8687
import org.apache.fineract.test.messaging.event.workingcapitalloan.transaction.WorkingCapitalLoanDisbursalTransactionBusinessEvent;
8788
import org.apache.fineract.test.messaging.event.workingcapitalloan.transaction.WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent;
8889
import org.springframework.beans.factory.annotation.Autowired;
@@ -318,6 +319,27 @@ public void workingCapitalLoanDisbursalTransactionEventCheck(final Long loanId,
318319
.extractingData(WorkingCapitalLoanTransactionDataV1::getReversed).isEqualTo(Boolean.FALSE);
319320
}
320321

322+
public void workingCapitalLoanCreditBalanceRefundTransactionEventCheck(final Long loanId, final BigDecimal expectedAmount) {
323+
waitForTransactionCommit();
324+
final GetWorkingCapitalLoansLoanIdResponse body = ok(
325+
() -> fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId));
326+
if (body.getTransactions() == null || body.getTransactions().isEmpty()) {
327+
throw new IllegalStateException("No Working Capital Loan transactions found");
328+
}
329+
330+
final GetWorkingCapitalLoanTransactionIdResponse cbrTransaction = body.getTransactions().stream()
331+
.filter(t -> t.getType() != null && "loanTransactionType.creditBalanceRefund".equals(t.getType().getCode())
332+
&& !Boolean.TRUE.equals(t.getReversed()))
333+
.reduce((first, second) -> second)
334+
.orElseThrow(() -> new IllegalStateException("Credit balance refund transaction not found"));
335+
336+
eventAssertion.assertEvent(WorkingCapitalLoanCreditBalanceRefundTransactionBusinessEvent.class, cbrTransaction.getId())//
337+
.extractingData(WorkingCapitalLoanTransactionDataV1::getWcLoanId).isEqualTo(loanId)//
338+
.extractingBigDecimal(WorkingCapitalLoanTransactionDataV1::getTransactionAmount)
339+
.isEqualTo(expectedAmount == null ? cbrTransaction.getTransactionAmount() : expectedAmount)//
340+
.extractingData(WorkingCapitalLoanTransactionDataV1::getReversed).isEqualTo(Boolean.FALSE);
341+
}
342+
321343
public void workingCapitalLoanUndoDisbursalTransactionEventCheck(final Long loanId) {
322344
workingCapitalLoanUndoDisbursalTransactionEventCheck(loanId, null);
323345
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.test.messaging.event.workingcapitalloan.transaction;
20+
21+
public class WorkingCapitalLoanCreditBalanceRefundTransactionBusinessEvent extends AbstractWorkingCapitalLoanTransactionEvent {
22+
23+
@Override
24+
public String getEventName() {
25+
return "WorkingCapitalLoanCreditBalanceRefundTransactionBusinessEvent";
26+
}
27+
}

0 commit comments

Comments
 (0)