FINERACT-1734-LoanRepaymentDue-Event-Enhancements-1
This commit is contained in:
committed by
Arnold Gálovics
parent
1405b28d71
commit
d80aa77c02
@@ -4,32 +4,16 @@
|
|||||||
"type": "record",
|
"type": "record",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"default": null,
|
"name": "loanId",
|
||||||
"name": "id",
|
"type": ["long"]
|
||||||
"type": [
|
},
|
||||||
"null",
|
{
|
||||||
"long"
|
"name": "loanAccountNo",
|
||||||
]
|
"type": ["string"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": null,
|
"default": null,
|
||||||
"name": "accountNo",
|
"name": "loanExternalId",
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": null,
|
|
||||||
"name": "externalId",
|
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": null,
|
|
||||||
"name": "dueDate",
|
|
||||||
"type": [
|
"type": [
|
||||||
"null",
|
"null",
|
||||||
"string"
|
"string"
|
||||||
@@ -44,19 +28,15 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": null,
|
"name": "installment",
|
||||||
"name": "totalLoanAmountDue",
|
"type": ["org.apache.fineract.avro.loan.v1.RepaymentDueDataV1"]
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"bigdecimal"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": null,
|
"default": null,
|
||||||
"name": "repaymentDue",
|
"name": "pastDueAmount",
|
||||||
"type": [
|
"type": [
|
||||||
"null",
|
"null",
|
||||||
"org.apache.fineract.avro.loan.v1.RepaymentDueDataV1"
|
"org.apache.fineract.avro.loan.v1.RepaymentPastDueDataV1"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,6 +11,14 @@
|
|||||||
"int"
|
"int"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "installmentDueDate",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"default": null,
|
"default": null,
|
||||||
"name": "principalAmountDue",
|
"name": "principalAmountDue",
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "RepaymentPastDueDataV1",
|
||||||
|
"namespace": "org.apache.fineract.avro.loan.v1",
|
||||||
|
"type": "record",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "totalAmount",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"bigdecimal"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "principalAmount",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"bigdecimal"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "interestAmount",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"bigdecimal"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "feeAmount",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"bigdecimal"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": null,
|
||||||
|
"name": "penaltyAmount",
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"bigdecimal"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+2
-2
@@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentOverdueBusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentDueBusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
||||||
@@ -45,7 +45,7 @@ public class CheckLoanRepaymentOverdueBusinessStep implements LoanCOBBusinessSte
|
|||||||
if (!repaymentSchedule.isObligationsMet()) {
|
if (!repaymentSchedule.isObligationsMet()) {
|
||||||
LocalDate installmentDueDate = repaymentSchedule.getDueDate();
|
LocalDate installmentDueDate = repaymentSchedule.getDueDate();
|
||||||
if (installmentDueDate.plusDays(numberOfDaysAfterDueDateToRaiseEvent).equals(currentDate)) {
|
if (installmentDueDate.plusDays(numberOfDaysAfterDueDateToRaiseEvent).equals(currentDate)) {
|
||||||
businessEventNotifierService.notifyPostBusinessEvent(new LoanRepaymentOverdueBusinessEvent(repaymentSchedule));
|
businessEventNotifierService.notifyPostBusinessEvent(new LoanRepaymentDueBusinessEvent(repaymentSchedule));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-4
@@ -25,6 +25,7 @@ import org.apache.fineract.avro.generator.ByteBufferSerializable;
|
|||||||
import org.apache.fineract.avro.generic.v1.CurrencyDataV1;
|
import org.apache.fineract.avro.generic.v1.CurrencyDataV1;
|
||||||
import org.apache.fineract.avro.loan.v1.LoanRepaymentDueDataV1;
|
import org.apache.fineract.avro.loan.v1.LoanRepaymentDueDataV1;
|
||||||
import org.apache.fineract.avro.loan.v1.RepaymentDueDataV1;
|
import org.apache.fineract.avro.loan.v1.RepaymentDueDataV1;
|
||||||
|
import org.apache.fineract.avro.loan.v1.RepaymentPastDueDataV1;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentBusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentBusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.support.AvroDateTimeMapper;
|
import org.apache.fineract.infrastructure.event.external.service.serialization.mapper.support.AvroDateTimeMapper;
|
||||||
@@ -46,25 +47,31 @@ public class LoanRepaymentBusinessEventSerializer extends AbstractBusinessEventS
|
|||||||
LoanRepaymentBusinessEvent event = (LoanRepaymentBusinessEvent) rawEvent;
|
LoanRepaymentBusinessEvent event = (LoanRepaymentBusinessEvent) rawEvent;
|
||||||
LoanRepaymentScheduleInstallment repaymentInstallment = event.get();
|
LoanRepaymentScheduleInstallment repaymentInstallment = event.get();
|
||||||
Loan loan = repaymentInstallment.getLoan();
|
Loan loan = repaymentInstallment.getLoan();
|
||||||
|
|
||||||
Long id = loan.getId();
|
Long id = loan.getId();
|
||||||
String accountNo = loan.getAccountNumber();
|
String accountNo = loan.getAccountNumber();
|
||||||
String externalId = loan.getExternalId().getValue();
|
String externalId = loan.getExternalId().getValue();
|
||||||
String dueDate = dataTimeMapper.mapLocalDate(repaymentInstallment.getDueDate());
|
|
||||||
MonetaryCurrency loanCurrency = loan.getCurrency();
|
MonetaryCurrency loanCurrency = loan.getCurrency();
|
||||||
CurrencyDataV1 currency = CurrencyDataV1.newBuilder().setCode(loanCurrency.getCode())
|
CurrencyDataV1 currency = CurrencyDataV1.newBuilder().setCode(loanCurrency.getCode())
|
||||||
.setDecimalPlaces(loanCurrency.getDigitsAfterDecimal()).setInMultiplesOf(loanCurrency.getCurrencyInMultiplesOf()).build();
|
.setDecimalPlaces(loanCurrency.getDigitsAfterDecimal()).setInMultiplesOf(loanCurrency.getCurrencyInMultiplesOf()).build();
|
||||||
BigDecimal totalLoanAmountDue = loan.getLoanSummary().getTotalOutstanding();
|
|
||||||
|
|
||||||
Integer installmentNumber = repaymentInstallment.getInstallmentNumber();
|
Integer installmentNumber = repaymentInstallment.getInstallmentNumber();
|
||||||
|
String dueDate = dataTimeMapper.mapLocalDate(repaymentInstallment.getDueDate());
|
||||||
BigDecimal principalAmountDue = repaymentInstallment.getPrincipalOutstanding(loanCurrency).getAmount();
|
BigDecimal principalAmountDue = repaymentInstallment.getPrincipalOutstanding(loanCurrency).getAmount();
|
||||||
BigDecimal interestAmountDue = repaymentInstallment.getInterestOutstanding(loanCurrency).getAmount();
|
BigDecimal interestAmountDue = repaymentInstallment.getInterestOutstanding(loanCurrency).getAmount();
|
||||||
BigDecimal feeChargeAmountDue = repaymentInstallment.getFeeChargesOutstanding(loanCurrency).getAmount();
|
BigDecimal feeChargeAmountDue = repaymentInstallment.getFeeChargesOutstanding(loanCurrency).getAmount();
|
||||||
BigDecimal penaltyChargeAmountDue = repaymentInstallment.getPenaltyChargesOutstanding(loanCurrency).getAmount();
|
BigDecimal penaltyChargeAmountDue = repaymentInstallment.getPenaltyChargesOutstanding(loanCurrency).getAmount();
|
||||||
BigDecimal totalAmountDue = repaymentInstallment.getTotalOutstanding(loanCurrency).getAmount();
|
BigDecimal totalAmountDue = repaymentInstallment.getTotalOutstanding(loanCurrency).getAmount();
|
||||||
|
|
||||||
RepaymentDueDataV1 repaymentDue = new RepaymentDueDataV1(installmentNumber, principalAmountDue, interestAmountDue,
|
RepaymentDueDataV1 repaymentDue = new RepaymentDueDataV1(installmentNumber, dueDate, principalAmountDue, interestAmountDue,
|
||||||
feeChargeAmountDue, penaltyChargeAmountDue, totalAmountDue);
|
feeChargeAmountDue, penaltyChargeAmountDue, totalAmountDue);
|
||||||
return new LoanRepaymentDueDataV1(id, accountNo, externalId, dueDate, currency, totalLoanAmountDue, repaymentDue);
|
|
||||||
|
RepaymentPastDueDataV1 pastDue = new RepaymentPastDueDataV1(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
|
||||||
|
BigDecimal.ZERO);
|
||||||
|
|
||||||
|
LoanRepaymentDueDataV1 loanRepaymentDueDataV1 = LoanRepaymentDueDataV1.newBuilder().setLoanId(id).setLoanAccountNo(accountNo)
|
||||||
|
.setLoanExternalId(externalId).setCurrency(currency).setInstallment(repaymentDue).setPastDueAmount(pastDue).build();
|
||||||
|
return loanRepaymentDueDataV1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-7
@@ -37,7 +37,7 @@ import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDoma
|
|||||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||||
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentOverdueBusinessEvent;
|
import org.apache.fineract.infrastructure.event.business.domain.loan.repayment.LoanRepaymentDueBusinessEvent;
|
||||||
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
||||||
@@ -68,8 +68,8 @@ public class CheckLoanRepaymentOverdueBusinessStepTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLoanWithInstallmentOverdueAfterConfiguredDaysWhenStepExecutionThenBusinessEventIsRaised() {
|
public void givenLoanWithInstallmentOverdueAfterConfiguredDaysWhenStepExecutionThenBusinessEventIsRaised() {
|
||||||
ArgumentCaptor<LoanRepaymentOverdueBusinessEvent> loanRepaymentOverdueBusinessEventArgumentCaptor = ArgumentCaptor
|
ArgumentCaptor<LoanRepaymentDueBusinessEvent> loanRepaymentDueBusinessEventArgumentCaptor = ArgumentCaptor
|
||||||
.forClass(LoanRepaymentOverdueBusinessEvent.class);
|
.forClass(LoanRepaymentDueBusinessEvent.class);
|
||||||
// given
|
// given
|
||||||
when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(1L);
|
when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(1L);
|
||||||
LocalDate loanInstallmentRepaymentDueDate = DateUtils.getBusinessLocalDate().minusDays(1);
|
LocalDate loanInstallmentRepaymentDueDate = DateUtils.getBusinessLocalDate().minusDays(1);
|
||||||
@@ -83,8 +83,8 @@ public class CheckLoanRepaymentOverdueBusinessStepTest {
|
|||||||
// when
|
// when
|
||||||
Loan processedLoan = underTest.execute(loanForProcessing);
|
Loan processedLoan = underTest.execute(loanForProcessing);
|
||||||
// then
|
// then
|
||||||
verify(businessEventNotifierService, times(1)).notifyPostBusinessEvent(loanRepaymentOverdueBusinessEventArgumentCaptor.capture());
|
verify(businessEventNotifierService, times(1)).notifyPostBusinessEvent(loanRepaymentDueBusinessEventArgumentCaptor.capture());
|
||||||
LoanRepaymentScheduleInstallment loanPayloadForEvent = loanRepaymentOverdueBusinessEventArgumentCaptor.getValue().get();
|
LoanRepaymentScheduleInstallment loanPayloadForEvent = loanRepaymentDueBusinessEventArgumentCaptor.getValue().get();
|
||||||
assertEquals(repaymentInstallment, loanPayloadForEvent);
|
assertEquals(repaymentInstallment, loanPayloadForEvent);
|
||||||
assertEquals(processedLoan, loanForProcessing);
|
assertEquals(processedLoan, loanForProcessing);
|
||||||
}
|
}
|
||||||
@@ -110,8 +110,6 @@ public class CheckLoanRepaymentOverdueBusinessStepTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLoanWithInstallmentOverdueAfterConfiguredDaysButInstallmentPaidOffWhenStepExecutionThenNoBusinessEvent() {
|
public void givenLoanWithInstallmentOverdueAfterConfiguredDaysButInstallmentPaidOffWhenStepExecutionThenNoBusinessEvent() {
|
||||||
ArgumentCaptor<LoanRepaymentOverdueBusinessEvent> loanRepaymentOverdueBusinessEventArgumentCaptor = ArgumentCaptor
|
|
||||||
.forClass(LoanRepaymentOverdueBusinessEvent.class);
|
|
||||||
// given
|
// given
|
||||||
when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(1L);
|
when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(1L);
|
||||||
LocalDate loanInstallmentRepaymentDueDate = DateUtils.getBusinessLocalDate().minusDays(1);
|
LocalDate loanInstallmentRepaymentDueDate = DateUtils.getBusinessLocalDate().minusDays(1);
|
||||||
|
|||||||
+50
-3
@@ -19,6 +19,8 @@
|
|||||||
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer.loan;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -31,9 +33,11 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.avro.AvroRuntimeException;
|
||||||
import org.apache.fineract.avro.generic.v1.CurrencyDataV1;
|
import org.apache.fineract.avro.generic.v1.CurrencyDataV1;
|
||||||
import org.apache.fineract.avro.loan.v1.LoanRepaymentDueDataV1;
|
import org.apache.fineract.avro.loan.v1.LoanRepaymentDueDataV1;
|
||||||
import org.apache.fineract.avro.loan.v1.RepaymentDueDataV1;
|
import org.apache.fineract.avro.loan.v1.RepaymentDueDataV1;
|
||||||
|
import org.apache.fineract.avro.loan.v1.RepaymentPastDueDataV1;
|
||||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
@@ -54,8 +58,11 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockedStatic;
|
import org.mockito.MockedStatic;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
public class LoanRepaymentBusinessEventSerializerTest {
|
public class LoanRepaymentBusinessEventSerializerTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@@ -103,12 +110,52 @@ public class LoanRepaymentBusinessEventSerializerTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
CurrencyDataV1 currency = CurrencyDataV1.newBuilder().setCode("CODE").setDecimalPlaces(1).setInMultiplesOf(1).build();
|
CurrencyDataV1 currency = CurrencyDataV1.newBuilder().setCode("CODE").setDecimalPlaces(1).setInMultiplesOf(1).build();
|
||||||
RepaymentDueDataV1 repaymentDue = new RepaymentDueDataV1(1, BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
RepaymentDueDataV1 repaymentDue = new RepaymentDueDataV1(1, loanInstallmentRepaymentDueDate.format(DateTimeFormatter.ISO_DATE),
|
||||||
|
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
||||||
|
BigDecimal.valueOf(0.0));
|
||||||
|
RepaymentPastDueDataV1 pastDue = new RepaymentPastDueDataV1(BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
||||||
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0));
|
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0));
|
||||||
LoanRepaymentDueDataV1 expectedSerializedData = new LoanRepaymentDueDataV1(1L, "0001", "externalId",
|
LoanRepaymentDueDataV1 expectedSerializedData = new LoanRepaymentDueDataV1(1L, "0001", "externalId", currency, repaymentDue,
|
||||||
loanInstallmentRepaymentDueDate.format(DateTimeFormatter.ISO_DATE), currency, BigDecimal.valueOf(0.0), repaymentDue);
|
pastDue);
|
||||||
|
|
||||||
assertEquals(data, expectedSerializedData);
|
assertEquals(data, expectedSerializedData);
|
||||||
moneyHelper.close();
|
moneyHelper.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoanRepaymentEventLoanIdMandatoryFieldValidation() {
|
||||||
|
// given
|
||||||
|
LoanRepaymentBusinessEventSerializer serializer = new LoanRepaymentBusinessEventSerializer(mapper);
|
||||||
|
|
||||||
|
LocalDate loanInstallmentRepaymentDueDate = DateUtils.getBusinessLocalDate().plusDays(1);
|
||||||
|
|
||||||
|
Loan loanForProcessing = Mockito.mock(Loan.class);
|
||||||
|
LoanProduct loanProduct = Mockito.mock(LoanProduct.class);
|
||||||
|
LoanSummary loanSummary = Mockito.mock(LoanSummary.class);
|
||||||
|
MonetaryCurrency loanCurrency = Mockito.mock(MonetaryCurrency.class);
|
||||||
|
MockedStatic<MoneyHelper> moneyHelper = Mockito.mockStatic(MoneyHelper.class);
|
||||||
|
|
||||||
|
LoanRepaymentScheduleInstallment repaymentInstallment = new LoanRepaymentScheduleInstallment(loanForProcessing, 1,
|
||||||
|
LocalDate.now(ZoneId.systemDefault()), loanInstallmentRepaymentDueDate, BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
|
||||||
|
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), false, new HashSet<>(), BigDecimal.valueOf(0.0));
|
||||||
|
LoanRepaymentDueBusinessEvent event = new LoanRepaymentDueBusinessEvent(repaymentInstallment);
|
||||||
|
|
||||||
|
// set mandatory loanID field as null
|
||||||
|
when(loanForProcessing.getId()).thenReturn(null);
|
||||||
|
when(loanForProcessing.getAccountNumber()).thenReturn("0001");
|
||||||
|
when(loanForProcessing.getExternalId()).thenReturn(ExternalIdFactory.produce("externalId"));
|
||||||
|
when(loanForProcessing.getLoanSummary()).thenReturn(loanSummary);
|
||||||
|
when(loanSummary.getTotalOutstanding()).thenReturn(BigDecimal.valueOf(0.0));
|
||||||
|
when(loanForProcessing.getCurrency()).thenReturn(loanCurrency);
|
||||||
|
when(loanCurrency.getCode()).thenReturn("CODE");
|
||||||
|
when(loanCurrency.getCurrencyInMultiplesOf()).thenReturn(1);
|
||||||
|
when(loanCurrency.getDigitsAfterDecimal()).thenReturn(1);
|
||||||
|
when(mapper.mapLocalDate(any())).thenReturn(loanInstallmentRepaymentDueDate.format(DateTimeFormatter.ISO_DATE));
|
||||||
|
moneyHelper.when(() -> MoneyHelper.getRoundingMode()).thenReturn(RoundingMode.UP);
|
||||||
|
|
||||||
|
// when
|
||||||
|
AvroRuntimeException exceptionThrown = assertThrows(AvroRuntimeException.class, () -> serializer.toAvroDTO(event));
|
||||||
|
assertTrue(exceptionThrown.getMessage().contains("does not accept null values"));
|
||||||
|
moneyHelper.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user