FINERACT-2279: Contract Termination - Undo
This commit is contained in:
committed by
Adam Saghy
parent
11cecb0d45
commit
ee29ce23ac
+4
@@ -305,6 +305,10 @@ public class LoanRequestFactory {
|
||||
.locale(DEFAULT_LOCALE).note("Capitalized Income");
|
||||
}
|
||||
|
||||
public static PostLoansLoanIdRequest defaultContractTerminationUndoRequest() {
|
||||
return new PostLoansLoanIdRequest().note("Contract Termination Undo");
|
||||
}
|
||||
|
||||
public static PostLoansLoanIdRequest defaultLoanContractTerminationRequest() {
|
||||
return new PostLoansLoanIdRequest().dateFormat(DATE_FORMAT).locale(DEFAULT_LOCALE).note("Contract Termination");
|
||||
}
|
||||
|
||||
+5
@@ -79,6 +79,7 @@ import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransaction
|
||||
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionMakeRepaymentPostEvent;
|
||||
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionMerchantIssuedRefundPostEvent;
|
||||
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionPayoutRefundPostEvent;
|
||||
import org.apache.fineract.test.messaging.event.loan.transaction.LoanUndoContractTerminationBusinessEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import retrofit2.Response;
|
||||
@@ -273,6 +274,10 @@ public class EventCheckHelper {
|
||||
eventAssertionBuilder.extractingData(LoanTransactionAdjustmentDataV1::getNewTransactionDetail).isEqualTo(null);
|
||||
}
|
||||
|
||||
public void loanUndoContractTerminationEventCheck(final GetLoansLoanIdTransactions transaction) {
|
||||
eventAssertion.assertEventRaised(LoanUndoContractTerminationBusinessEvent.class, transaction.getId());
|
||||
}
|
||||
|
||||
private boolean areBigDecimalValuesEqual(BigDecimal actual, BigDecimal expected) {
|
||||
log.debug("--- Checking BigDecimal values.... ---");
|
||||
log.debug("Actual: {}", actual);
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.fineract.test.messaging.event.loan.transaction;
|
||||
|
||||
public class LoanUndoContractTerminationBusinessEvent extends AbstractLoanTransactionEvent {
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return "LoanUndoContractTerminationBusinessEvent";
|
||||
}
|
||||
}
|
||||
+29
@@ -4471,6 +4471,35 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
.isEqualTo(transactionId);
|
||||
}
|
||||
|
||||
@And("Admin successfully undoes loan contract termination")
|
||||
public void undoLoanContractTermination() throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
assert loanResponse.body() != null;
|
||||
final Response<PostLoansLoanIdResponse> loanContractTerminationResponse = testContext()
|
||||
.get(TestContextKey.LOAN_CONTRACT_TERMINATION_RESPONSE);
|
||||
assert loanContractTerminationResponse.body() != null;
|
||||
final Long loanId = loanResponse.body().getLoanId();
|
||||
|
||||
final List<GetLoansLoanIdTransactions> transactions = Objects
|
||||
.requireNonNull(loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute().body()).getTransactions();
|
||||
|
||||
assert transactions != null;
|
||||
final GetLoansLoanIdTransactions targetTransaction = transactions.stream().filter(t -> {
|
||||
assert t.getType() != null;
|
||||
return Boolean.TRUE.equals(t.getType().getContractTermination());
|
||||
}).findFirst().orElse(null);
|
||||
|
||||
final PostLoansLoanIdRequest request = LoanRequestFactory.defaultContractTerminationUndoRequest();
|
||||
|
||||
final Response<PostLoansLoanIdResponse> response = loansApi.stateTransitions(loanId, request, "undoContractTermination").execute();
|
||||
testContext().set(TestContextKey.LOAN_UNDO_CONTRACT_TERMINATION_RESPONSE, response);
|
||||
ErrorHelper.checkSuccessfulApiCall(response);
|
||||
assert targetTransaction != null;
|
||||
eventCheckHelper.checkTransactionWithLoanTransactionAdjustmentBizEvent(targetTransaction);
|
||||
eventCheckHelper.loanUndoContractTerminationEventCheck(targetTransaction);
|
||||
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
|
||||
}
|
||||
|
||||
@Then("LoanTransactionContractTerminationPostBusinessEvent is raised on {string}")
|
||||
public void checkLoanTransactionContractTerminationPostBusinessEvent(final String date) throws IOException {
|
||||
final Response<PostLoansResponse> loanCreateResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
|
||||
+1
@@ -228,4 +228,5 @@ public abstract class TestContextKey {
|
||||
public static final String LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE = "loanCapitalizedIncomeAdjustmentResponse";
|
||||
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_CONTRACT_TERMINATION = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalculationContractTermination";
|
||||
public static final String LOAN_CONTRACT_TERMINATION_RESPONSE = "loanContractTerminationResponse";
|
||||
public static final String LOAN_UNDO_CONTRACT_TERMINATION_RESPONSE = "loanUndoContractTerminationResponse";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user