2323
2424import java .io .IOException ;
2525import java .math .BigDecimal ;
26- import java .math .MathContext ;
2726import java .time .format .DateTimeFormatter ;
2827import java .util .List ;
2928import lombok .RequiredArgsConstructor ;
@@ -198,7 +197,7 @@ private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClaz
198197 Long clientIdExpected = body .getClientId ();
199198 BigDecimal principalDisbursedActual = loanAccountDataV1 .getSummary ().getPrincipalDisbursed ();
200199 Double principalDisbursedExpectedDouble = body .getSummary ().getPrincipalDisbursed ();
201- BigDecimal principalDisbursedExpected = new BigDecimal (principalDisbursedExpectedDouble , MathContext . DECIMAL64 );
200+ BigDecimal principalDisbursedExpected = BigDecimal . valueOf (principalDisbursedExpectedDouble );
202201 String actualDisbursementDateActual = loanAccountDataV1 .getTimeline ().getActualDisbursementDate ();
203202 String actualDisbursementDateExpected = FORMATTER_EVENTS .format (body .getTimeline ().getActualDisbursementDate ());
204203 String currencyCodeActual = loanAccountDataV1 .getSummary ().getCurrency ().getCode ();
@@ -210,8 +209,7 @@ private void loanAccountDataV1Check(Class<? extends AbstractLoanEvent> eventClaz
210209 BigDecimal totalUnpaidPayableNotDueInterestExpected = body .getSummary ().getTotalUnpaidPayableNotDueInterest ();
211210 BigDecimal totalInterestPaymentWaiverActual = loanAccountDataV1 .getSummary ().getTotalInterestPaymentWaiver ();
212211 Double totalInterestPaymentWaiverExpectedDouble = body .getSummary ().getTotalInterestPaymentWaiver ();
213- BigDecimal totalInterestPaymentWaiverExpected = new BigDecimal (totalInterestPaymentWaiverExpectedDouble ,
214- MathContext .DECIMAL64 );
212+ BigDecimal totalInterestPaymentWaiverExpected = BigDecimal .valueOf (totalInterestPaymentWaiverExpectedDouble );
215213 BigDecimal delinquentInterestActual = loanAccountDataV1 .getDelinquent ().getDelinquentInterest ();
216214 BigDecimal delinquentInterestExpected = body .getDelinquent ().getDelinquentInterest ();
217215 BigDecimal delinquentFeeActual = loanAccountDataV1 .getDelinquent ().getDelinquentFee ();
@@ -336,12 +334,12 @@ public void loanOwnershipTransferBusinessEventCheck(Long loanId, Long transferId
336334 ExternalTransferData filtered = content .stream ().filter (t -> transferId .equals (t .getTransferId ())).reduce ((first , second ) -> second )
337335 .orElseThrow (() -> new IllegalStateException ("No element found" ));
338336
339- BigDecimal totalOutstandingBalanceAmountExpected = zeroConversion (filtered .getDetails ().getTotalOutstanding ());
340- BigDecimal outstandingPrincipalPortionExpected = zeroConversion (filtered .getDetails ().getTotalPrincipalOutstanding ());
341- BigDecimal outstandingFeePortionExpected = zeroConversion (filtered .getDetails ().getTotalFeeChargesOutstanding ());
342- BigDecimal outstandingPenaltyPortionExpected = zeroConversion (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
343- BigDecimal outstandingInterestPortionExpected = zeroConversion (filtered .getDetails ().getTotalInterestOutstanding ());
344- BigDecimal overPaymentPortionExpected = zeroConversion (filtered .getDetails ().getTotalOverpaid ());
337+ BigDecimal totalOutstandingBalanceAmountExpected = convertToDefaultScaling (filtered .getDetails ().getTotalOutstanding ());
338+ BigDecimal outstandingPrincipalPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalPrincipalOutstanding ());
339+ BigDecimal outstandingFeePortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalFeeChargesOutstanding ());
340+ BigDecimal outstandingPenaltyPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
341+ BigDecimal outstandingInterestPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalInterestOutstanding ());
342+ BigDecimal overPaymentPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalOverpaid ());
345343
346344 eventAssertion .assertEvent (LoanOwnershipTransferEvent .class , loanId ).extractingData (LoanOwnershipTransferDataV1 ::getLoanId )
347345 .isEqualTo (loanId ).extractingData (LoanOwnershipTransferDataV1 ::getAssetOwnerExternalId )
@@ -368,17 +366,17 @@ public void loanOwnershipTransferBusinessEventWithStatusCheck(Long loanId, Long
368366 .orElseThrow (() -> new IllegalStateException ("No element found" ));
369367
370368 BigDecimal totalOutstandingBalanceAmountExpected = filtered .getDetails () == null ? null
371- : zeroConversion (filtered .getDetails ().getTotalOutstanding ());
369+ : convertToDefaultScaling (filtered .getDetails ().getTotalOutstanding ());
372370 BigDecimal outstandingPrincipalPortionExpected = filtered .getDetails () == null ? null
373- : zeroConversion (filtered .getDetails ().getTotalPrincipalOutstanding ());
371+ : convertToDefaultScaling (filtered .getDetails ().getTotalPrincipalOutstanding ());
374372 BigDecimal outstandingFeePortionExpected = filtered .getDetails () == null ? null
375- : zeroConversion (filtered .getDetails ().getTotalFeeChargesOutstanding ());
373+ : convertToDefaultScaling (filtered .getDetails ().getTotalFeeChargesOutstanding ());
376374 BigDecimal outstandingPenaltyPortionExpected = filtered .getDetails () == null ? null
377- : zeroConversion (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
375+ : convertToDefaultScaling (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
378376 BigDecimal outstandingInterestPortionExpected = filtered .getDetails () == null ? null
379- : zeroConversion (filtered .getDetails ().getTotalInterestOutstanding ());
377+ : convertToDefaultScaling (filtered .getDetails ().getTotalInterestOutstanding ());
380378 BigDecimal overPaymentPortionExpected = filtered .getDetails () == null ? null
381- : zeroConversion (filtered .getDetails ().getTotalOverpaid ());
379+ : convertToDefaultScaling (filtered .getDetails ().getTotalOverpaid ());
382380
383381 AssetExternalizationTransferStatus transferStatusType = AssetExternalizationTransferStatus .valueOf (transferStatus );
384382 String transferStatusExpected = transferStatusType .getValue ();
@@ -415,12 +413,12 @@ public void loanAccountSnapshotBusinessEventCheck(Long loanId, Long transferId)
415413 String ownerExternalIdExpected = filtered .getStatus ().getValue ().equals ("BUYBACK" ) ? null : filtered .getOwner ().getExternalId ();
416414 String settlementDateExpected = filtered .getStatus ().getValue ().equals ("BUYBACK" ) ? null
417415 : FORMATTER_EVENTS .format (filtered .getSettlementDate ());
418- BigDecimal totalOutstandingBalanceAmountExpected = zeroConversion (filtered .getDetails ().getTotalOutstanding ());
419- BigDecimal outstandingPrincipalPortionExpected = zeroConversion (filtered .getDetails ().getTotalPrincipalOutstanding ());
420- BigDecimal outstandingFeePortionExpected = zeroConversion (filtered .getDetails ().getTotalFeeChargesOutstanding ());
421- BigDecimal outstandingPenaltyPortionExpected = zeroConversion (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
422- BigDecimal outstandingInterestPortionExpected = zeroConversion (filtered .getDetails ().getTotalInterestOutstanding ());
423- BigDecimal overPaymentPortionExpected = zeroConversion (filtered .getDetails ().getTotalOverpaid ());
416+ BigDecimal totalOutstandingBalanceAmountExpected = convertToDefaultScaling (filtered .getDetails ().getTotalOutstanding ());
417+ BigDecimal outstandingPrincipalPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalPrincipalOutstanding ());
418+ BigDecimal outstandingFeePortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalFeeChargesOutstanding ());
419+ BigDecimal outstandingPenaltyPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalPenaltyChargesOutstanding ());
420+ BigDecimal outstandingInterestPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalInterestOutstanding ());
421+ BigDecimal overPaymentPortionExpected = convertToDefaultScaling (filtered .getDetails ().getTotalOverpaid ());
424422
425423 eventAssertion .assertEvent (LoanAccountSnapshotEvent .class , loanId ).extractingData (LoanAccountDataV1 ::getId ).isEqualTo (loanId )
426424 .extractingData (LoanAccountDataV1 ::getExternalOwnerId ).isEqualTo (ownerExternalIdExpected )
@@ -520,7 +518,7 @@ public void installmentLevelDelinquencyRangeChangeEventCheck(Long loanId) {
520518 });
521519 }
522520
523- private BigDecimal zeroConversion (BigDecimal input ) {
524- return input .compareTo ( new BigDecimal ( "0.000000" )) == 0 ? new BigDecimal ( input . toEngineeringString ()) : input . setScale (8 );
521+ private BigDecimal convertToDefaultScaling (BigDecimal input ) {
522+ return input .setScale (8 );
525523 }
526524}
0 commit comments