FINERACT-1724 - Remove Restriction from faurd mark
This commit is contained in:
-5
@@ -2521,11 +2521,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
Loan loan = this.loanAssembler.assembleFrom(loanId);
|
Loan loan = this.loanAssembler.assembleFrom(loanId);
|
||||||
final Map<String, Object> changes = new LinkedHashMap<>();
|
final Map<String, Object> changes = new LinkedHashMap<>();
|
||||||
|
|
||||||
if (!loan.isOpen()) {
|
|
||||||
throw new GeneralPlatformDomainRuleException("error.msg.loan.mark.as.fraud.not.allowed",
|
|
||||||
"Loan Id: " + loanId + " mark as fraud is not allowed as loan status is not active", loan.getStatus().getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean fraud = command.booleanPrimitiveValueOfParameterNamed(LoanApiConstants.FRAUD_ATTRIBUTE_NAME);
|
final boolean fraud = command.booleanPrimitiveValueOfParameterNamed(LoanApiConstants.FRAUD_ATTRIBUTE_NAME);
|
||||||
if (loan.isFraud() != fraud) {
|
if (loan.isFraud() != fraud) {
|
||||||
loan.markAsFraud(fraud);
|
loan.markAsFraud(fraud);
|
||||||
|
|||||||
+47
-38
@@ -32,7 +32,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
|
import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
|
||||||
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||||
import org.apache.fineract.client.models.PutLoansLoanIdResponse;
|
import org.apache.fineract.client.models.PutLoansLoanIdResponse;
|
||||||
|
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||||
|
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
|
||||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||||
|
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
|
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||||
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
|
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
|
||||||
@@ -69,54 +72,60 @@ public class LoanAccountFraudTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMarkLoanAsFraud() {
|
public void testMarkLoanAsFraud() {
|
||||||
final String command = "markAsFraud";
|
try {
|
||||||
// Client and Loan account creation
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||||
final Integer loanId = createAccounts(15, 1);
|
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate);
|
||||||
|
final String command = "markAsFraud";
|
||||||
|
// Client and Loan account creation
|
||||||
|
final Integer loanId = createAccounts(15, 1);
|
||||||
|
|
||||||
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
assertNotNull(getLoansLoanIdResponse);
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
|
|
||||||
// Default values Not Null and False
|
// Default values Not Null and False
|
||||||
assertNotNull(getLoansLoanIdResponse.getFraud());
|
assertNotNull(getLoansLoanIdResponse.getFraud());
|
||||||
assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
|
assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
|
||||||
|
|
||||||
String payload = loanTransactionHelper.getLoanFraudPayloadAsJSON("fraud", "true");
|
String payload = loanTransactionHelper.getLoanFraudPayloadAsJSON("fraud", "true");
|
||||||
// Send the request expecting an error because the Loan is not active yet
|
// Send the request, not expecting any errors (because only open loan restriction removed)
|
||||||
PutLoansLoanIdResponse putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload,
|
PutLoansLoanIdResponse putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload,
|
||||||
this.responseSpecError);
|
this.responseSpec);
|
||||||
|
|
||||||
String statusCode = getLoansLoanIdResponse.getStatus().getCode();
|
String statusCode = getLoansLoanIdResponse.getStatus().getCode();
|
||||||
log.info("Loan with Id {} is with Status {}", getLoansLoanIdResponse.getId(), statusCode);
|
log.info("Loan with Id {} is with Status {}", getLoansLoanIdResponse.getId(), statusCode);
|
||||||
|
|
||||||
// Approve the Loan active
|
// Approve the Loan active
|
||||||
approveAndDisburseLoan(loanId, this.operationDate, this.amountVal);
|
approveAndDisburseLoan(loanId, this.operationDate, this.amountVal);
|
||||||
|
|
||||||
// Default values Not Null and False
|
// Default values Not Null and False
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
assertNotNull(getLoansLoanIdResponse);
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
assertNotNull(getLoansLoanIdResponse.getFraud());
|
assertNotNull(getLoansLoanIdResponse.getFraud());
|
||||||
assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
|
assertEquals(Boolean.TRUE, getLoansLoanIdResponse.getFraud());
|
||||||
statusCode = getLoansLoanIdResponse.getStatus().getCode();
|
statusCode = getLoansLoanIdResponse.getStatus().getCode();
|
||||||
log.info("Loan with Id {} is with Status {}", getLoansLoanIdResponse.getId(), statusCode);
|
log.info("Loan with Id {} is with Status {}", getLoansLoanIdResponse.getId(), statusCode);
|
||||||
|
|
||||||
// Mark On the Fraud
|
// Mark On the Fraud
|
||||||
putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload, this.responseSpec);
|
putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload, this.responseSpec);
|
||||||
assertNotNull(putLoansLoanIdResponse);
|
assertNotNull(putLoansLoanIdResponse);
|
||||||
|
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
assertNotNull(getLoansLoanIdResponse);
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
assertNotNull(getLoansLoanIdResponse.getFraud());
|
assertNotNull(getLoansLoanIdResponse.getFraud());
|
||||||
assertEquals(Boolean.TRUE, getLoansLoanIdResponse.getFraud());
|
assertEquals(Boolean.TRUE, getLoansLoanIdResponse.getFraud());
|
||||||
|
|
||||||
// Mark Off the Fraud
|
// Mark Off the Fraud
|
||||||
payload = loanTransactionHelper.getLoanFraudPayloadAsJSON("fraud", "false");
|
payload = loanTransactionHelper.getLoanFraudPayloadAsJSON("fraud", "false");
|
||||||
putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload, this.responseSpec);
|
putLoansLoanIdResponse = loanTransactionHelper.modifyLoanCommand(loanId, command, payload, this.responseSpec);
|
||||||
assertNotNull(putLoansLoanIdResponse);
|
assertNotNull(putLoansLoanIdResponse);
|
||||||
|
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
assertNotNull(getLoansLoanIdResponse);
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
assertNotNull(getLoansLoanIdResponse.getFraud());
|
assertNotNull(getLoansLoanIdResponse.getFraud());
|
||||||
assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
|
assertEquals(Boolean.FALSE, getLoansLoanIdResponse.getFraud());
|
||||||
|
} finally {
|
||||||
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createAccounts(final Integer daysToSubtract, final Integer numberOfRepayments) {
|
private Integer createAccounts(final Integer daysToSubtract, final Integer numberOfRepayments) {
|
||||||
|
|||||||
Reference in New Issue
Block a user