19TEST(LoanTests, BuilderSettersRoundTrip)
53 previousTxnLgrSeqValue,
85 EXPECT_TRUE(builder.validate());
87 auto const entry = builder.build(index);
89 EXPECT_TRUE(entry.validate());
92 auto const& expected = previousTxnIDValue;
93 auto const actual = entry.getPreviousTxnID();
98 auto const& expected = previousTxnLgrSeqValue;
99 auto const actual = entry.getPreviousTxnLgrSeq();
104 auto const& expected = ownerNodeValue;
105 auto const actual = entry.getOwnerNode();
110 auto const& expected = loanBrokerNodeValue;
111 auto const actual = entry.getLoanBrokerNode();
116 auto const& expected = loanBrokerIDValue;
117 auto const actual = entry.getLoanBrokerID();
122 auto const& expected = loanSequenceValue;
123 auto const actual = entry.getLoanSequence();
128 auto const& expected = borrowerValue;
129 auto const actual = entry.getBorrower();
134 auto const& expected = startDateValue;
135 auto const actual = entry.getStartDate();
140 auto const& expected = paymentIntervalValue;
141 auto const actual = entry.getPaymentInterval();
146 auto const& expected = periodicPaymentValue;
147 auto const actual = entry.getPeriodicPayment();
152 auto const& expected = loanOriginationFeeValue;
153 auto const actualOpt = entry.getLoanOriginationFee();
154 ASSERT_TRUE(actualOpt.has_value());
156 EXPECT_TRUE(entry.hasLoanOriginationFee());
160 auto const& expected = loanServiceFeeValue;
161 auto const actualOpt = entry.getLoanServiceFee();
162 ASSERT_TRUE(actualOpt.has_value());
164 EXPECT_TRUE(entry.hasLoanServiceFee());
168 auto const& expected = latePaymentFeeValue;
169 auto const actualOpt = entry.getLatePaymentFee();
170 ASSERT_TRUE(actualOpt.has_value());
172 EXPECT_TRUE(entry.hasLatePaymentFee());
176 auto const& expected = closePaymentFeeValue;
177 auto const actualOpt = entry.getClosePaymentFee();
178 ASSERT_TRUE(actualOpt.has_value());
180 EXPECT_TRUE(entry.hasClosePaymentFee());
184 auto const& expected = overpaymentFeeValue;
185 auto const actualOpt = entry.getOverpaymentFee();
186 ASSERT_TRUE(actualOpt.has_value());
188 EXPECT_TRUE(entry.hasOverpaymentFee());
192 auto const& expected = interestRateValue;
193 auto const actualOpt = entry.getInterestRate();
194 ASSERT_TRUE(actualOpt.has_value());
196 EXPECT_TRUE(entry.hasInterestRate());
200 auto const& expected = lateInterestRateValue;
201 auto const actualOpt = entry.getLateInterestRate();
202 ASSERT_TRUE(actualOpt.has_value());
204 EXPECT_TRUE(entry.hasLateInterestRate());
208 auto const& expected = closeInterestRateValue;
209 auto const actualOpt = entry.getCloseInterestRate();
210 ASSERT_TRUE(actualOpt.has_value());
212 EXPECT_TRUE(entry.hasCloseInterestRate());
216 auto const& expected = overpaymentInterestRateValue;
217 auto const actualOpt = entry.getOverpaymentInterestRate();
218 ASSERT_TRUE(actualOpt.has_value());
220 EXPECT_TRUE(entry.hasOverpaymentInterestRate());
224 auto const& expected = gracePeriodValue;
225 auto const actualOpt = entry.getGracePeriod();
226 ASSERT_TRUE(actualOpt.has_value());
228 EXPECT_TRUE(entry.hasGracePeriod());
232 auto const& expected = previousPaymentDueDateValue;
233 auto const actualOpt = entry.getPreviousPaymentDueDate();
234 ASSERT_TRUE(actualOpt.has_value());
236 EXPECT_TRUE(entry.hasPreviousPaymentDueDate());
240 auto const& expected = nextPaymentDueDateValue;
241 auto const actualOpt = entry.getNextPaymentDueDate();
242 ASSERT_TRUE(actualOpt.has_value());
244 EXPECT_TRUE(entry.hasNextPaymentDueDate());
248 auto const& expected = paymentRemainingValue;
249 auto const actualOpt = entry.getPaymentRemaining();
250 ASSERT_TRUE(actualOpt.has_value());
252 EXPECT_TRUE(entry.hasPaymentRemaining());
256 auto const& expected = principalOutstandingValue;
257 auto const actualOpt = entry.getPrincipalOutstanding();
258 ASSERT_TRUE(actualOpt.has_value());
260 EXPECT_TRUE(entry.hasPrincipalOutstanding());
264 auto const& expected = totalValueOutstandingValue;
265 auto const actualOpt = entry.getTotalValueOutstanding();
266 ASSERT_TRUE(actualOpt.has_value());
268 EXPECT_TRUE(entry.hasTotalValueOutstanding());
272 auto const& expected = managementFeeOutstandingValue;
273 auto const actualOpt = entry.getManagementFeeOutstanding();
274 ASSERT_TRUE(actualOpt.has_value());
276 EXPECT_TRUE(entry.hasManagementFeeOutstanding());
280 auto const& expected = loanScaleValue;
281 auto const actualOpt = entry.getLoanScale();
282 ASSERT_TRUE(actualOpt.has_value());
284 EXPECT_TRUE(entry.hasLoanScale());
287 EXPECT_TRUE(entry.hasLedgerIndex());
288 auto const ledgerIndex = entry.getLedgerIndex();
289 ASSERT_TRUE(ledgerIndex.has_value());
290 EXPECT_EQ(*ledgerIndex, index);
291 EXPECT_EQ(entry.getKey(), index);
296TEST(LoanTests, BuilderFromSleRoundTrip)
330 sle->at(sfPreviousTxnID) = previousTxnIDValue;
331 sle->at(sfPreviousTxnLgrSeq) = previousTxnLgrSeqValue;
332 sle->at(sfOwnerNode) = ownerNodeValue;
333 sle->at(sfLoanBrokerNode) = loanBrokerNodeValue;
334 sle->at(sfLoanBrokerID) = loanBrokerIDValue;
335 sle->at(sfLoanSequence) = loanSequenceValue;
336 sle->at(sfBorrower) = borrowerValue;
337 sle->at(sfLoanOriginationFee) = loanOriginationFeeValue;
338 sle->at(sfLoanServiceFee) = loanServiceFeeValue;
339 sle->at(sfLatePaymentFee) = latePaymentFeeValue;
340 sle->at(sfClosePaymentFee) = closePaymentFeeValue;
341 sle->at(sfOverpaymentFee) = overpaymentFeeValue;
342 sle->at(sfInterestRate) = interestRateValue;
343 sle->at(sfLateInterestRate) = lateInterestRateValue;
344 sle->at(sfCloseInterestRate) = closeInterestRateValue;
345 sle->at(sfOverpaymentInterestRate) = overpaymentInterestRateValue;
346 sle->at(sfStartDate) = startDateValue;
347 sle->at(sfPaymentInterval) = paymentIntervalValue;
348 sle->at(sfGracePeriod) = gracePeriodValue;
349 sle->at(sfPreviousPaymentDueDate) = previousPaymentDueDateValue;
350 sle->at(sfNextPaymentDueDate) = nextPaymentDueDateValue;
351 sle->at(sfPaymentRemaining) = paymentRemainingValue;
352 sle->at(sfPeriodicPayment) = periodicPaymentValue;
353 sle->at(sfPrincipalOutstanding) = principalOutstandingValue;
354 sle->at(sfTotalValueOutstanding) = totalValueOutstandingValue;
355 sle->at(sfManagementFeeOutstanding) = managementFeeOutstandingValue;
356 sle->at(sfLoanScale) = loanScaleValue;
359 EXPECT_TRUE(builderFromSle.validate());
361 auto const entryFromBuilder = builderFromSle.build(index);
363 Loan entryFromSle{sle};
364 EXPECT_TRUE(entryFromBuilder.validate());
365 EXPECT_TRUE(entryFromSle.validate());
368 auto const& expected = previousTxnIDValue;
370 auto const fromSle = entryFromSle.getPreviousTxnID();
371 auto const fromBuilder = entryFromBuilder.getPreviousTxnID();
378 auto const& expected = previousTxnLgrSeqValue;
380 auto const fromSle = entryFromSle.getPreviousTxnLgrSeq();
381 auto const fromBuilder = entryFromBuilder.getPreviousTxnLgrSeq();
388 auto const& expected = ownerNodeValue;
390 auto const fromSle = entryFromSle.getOwnerNode();
391 auto const fromBuilder = entryFromBuilder.getOwnerNode();
398 auto const& expected = loanBrokerNodeValue;
400 auto const fromSle = entryFromSle.getLoanBrokerNode();
401 auto const fromBuilder = entryFromBuilder.getLoanBrokerNode();
408 auto const& expected = loanBrokerIDValue;
410 auto const fromSle = entryFromSle.getLoanBrokerID();
411 auto const fromBuilder = entryFromBuilder.getLoanBrokerID();
418 auto const& expected = loanSequenceValue;
420 auto const fromSle = entryFromSle.getLoanSequence();
421 auto const fromBuilder = entryFromBuilder.getLoanSequence();
428 auto const& expected = borrowerValue;
430 auto const fromSle = entryFromSle.getBorrower();
431 auto const fromBuilder = entryFromBuilder.getBorrower();
438 auto const& expected = startDateValue;
440 auto const fromSle = entryFromSle.getStartDate();
441 auto const fromBuilder = entryFromBuilder.getStartDate();
448 auto const& expected = paymentIntervalValue;
450 auto const fromSle = entryFromSle.getPaymentInterval();
451 auto const fromBuilder = entryFromBuilder.getPaymentInterval();
458 auto const& expected = periodicPaymentValue;
460 auto const fromSle = entryFromSle.getPeriodicPayment();
461 auto const fromBuilder = entryFromBuilder.getPeriodicPayment();
468 auto const& expected = loanOriginationFeeValue;
470 auto const fromSleOpt = entryFromSle.getLoanOriginationFee();
471 auto const fromBuilderOpt = entryFromBuilder.getLoanOriginationFee();
473 ASSERT_TRUE(fromSleOpt.has_value());
474 ASSERT_TRUE(fromBuilderOpt.has_value());
481 auto const& expected = loanServiceFeeValue;
483 auto const fromSleOpt = entryFromSle.getLoanServiceFee();
484 auto const fromBuilderOpt = entryFromBuilder.getLoanServiceFee();
486 ASSERT_TRUE(fromSleOpt.has_value());
487 ASSERT_TRUE(fromBuilderOpt.has_value());
494 auto const& expected = latePaymentFeeValue;
496 auto const fromSleOpt = entryFromSle.getLatePaymentFee();
497 auto const fromBuilderOpt = entryFromBuilder.getLatePaymentFee();
499 ASSERT_TRUE(fromSleOpt.has_value());
500 ASSERT_TRUE(fromBuilderOpt.has_value());
507 auto const& expected = closePaymentFeeValue;
509 auto const fromSleOpt = entryFromSle.getClosePaymentFee();
510 auto const fromBuilderOpt = entryFromBuilder.getClosePaymentFee();
512 ASSERT_TRUE(fromSleOpt.has_value());
513 ASSERT_TRUE(fromBuilderOpt.has_value());
520 auto const& expected = overpaymentFeeValue;
522 auto const fromSleOpt = entryFromSle.getOverpaymentFee();
523 auto const fromBuilderOpt = entryFromBuilder.getOverpaymentFee();
525 ASSERT_TRUE(fromSleOpt.has_value());
526 ASSERT_TRUE(fromBuilderOpt.has_value());
533 auto const& expected = interestRateValue;
535 auto const fromSleOpt = entryFromSle.getInterestRate();
536 auto const fromBuilderOpt = entryFromBuilder.getInterestRate();
538 ASSERT_TRUE(fromSleOpt.has_value());
539 ASSERT_TRUE(fromBuilderOpt.has_value());
546 auto const& expected = lateInterestRateValue;
548 auto const fromSleOpt = entryFromSle.getLateInterestRate();
549 auto const fromBuilderOpt = entryFromBuilder.getLateInterestRate();
551 ASSERT_TRUE(fromSleOpt.has_value());
552 ASSERT_TRUE(fromBuilderOpt.has_value());
559 auto const& expected = closeInterestRateValue;
561 auto const fromSleOpt = entryFromSle.getCloseInterestRate();
562 auto const fromBuilderOpt = entryFromBuilder.getCloseInterestRate();
564 ASSERT_TRUE(fromSleOpt.has_value());
565 ASSERT_TRUE(fromBuilderOpt.has_value());
572 auto const& expected = overpaymentInterestRateValue;
574 auto const fromSleOpt = entryFromSle.getOverpaymentInterestRate();
575 auto const fromBuilderOpt = entryFromBuilder.getOverpaymentInterestRate();
577 ASSERT_TRUE(fromSleOpt.has_value());
578 ASSERT_TRUE(fromBuilderOpt.has_value());
585 auto const& expected = gracePeriodValue;
587 auto const fromSleOpt = entryFromSle.getGracePeriod();
588 auto const fromBuilderOpt = entryFromBuilder.getGracePeriod();
590 ASSERT_TRUE(fromSleOpt.has_value());
591 ASSERT_TRUE(fromBuilderOpt.has_value());
598 auto const& expected = previousPaymentDueDateValue;
600 auto const fromSleOpt = entryFromSle.getPreviousPaymentDueDate();
601 auto const fromBuilderOpt = entryFromBuilder.getPreviousPaymentDueDate();
603 ASSERT_TRUE(fromSleOpt.has_value());
604 ASSERT_TRUE(fromBuilderOpt.has_value());
611 auto const& expected = nextPaymentDueDateValue;
613 auto const fromSleOpt = entryFromSle.getNextPaymentDueDate();
614 auto const fromBuilderOpt = entryFromBuilder.getNextPaymentDueDate();
616 ASSERT_TRUE(fromSleOpt.has_value());
617 ASSERT_TRUE(fromBuilderOpt.has_value());
624 auto const& expected = paymentRemainingValue;
626 auto const fromSleOpt = entryFromSle.getPaymentRemaining();
627 auto const fromBuilderOpt = entryFromBuilder.getPaymentRemaining();
629 ASSERT_TRUE(fromSleOpt.has_value());
630 ASSERT_TRUE(fromBuilderOpt.has_value());
637 auto const& expected = principalOutstandingValue;
639 auto const fromSleOpt = entryFromSle.getPrincipalOutstanding();
640 auto const fromBuilderOpt = entryFromBuilder.getPrincipalOutstanding();
642 ASSERT_TRUE(fromSleOpt.has_value());
643 ASSERT_TRUE(fromBuilderOpt.has_value());
650 auto const& expected = totalValueOutstandingValue;
652 auto const fromSleOpt = entryFromSle.getTotalValueOutstanding();
653 auto const fromBuilderOpt = entryFromBuilder.getTotalValueOutstanding();
655 ASSERT_TRUE(fromSleOpt.has_value());
656 ASSERT_TRUE(fromBuilderOpt.has_value());
663 auto const& expected = managementFeeOutstandingValue;
665 auto const fromSleOpt = entryFromSle.getManagementFeeOutstanding();
666 auto const fromBuilderOpt = entryFromBuilder.getManagementFeeOutstanding();
668 ASSERT_TRUE(fromSleOpt.has_value());
669 ASSERT_TRUE(fromBuilderOpt.has_value());
676 auto const& expected = loanScaleValue;
678 auto const fromSleOpt = entryFromSle.getLoanScale();
679 auto const fromBuilderOpt = entryFromBuilder.getLoanScale();
681 ASSERT_TRUE(fromSleOpt.has_value());
682 ASSERT_TRUE(fromBuilderOpt.has_value());
688 EXPECT_EQ(entryFromSle.getKey(), index);
689 EXPECT_EQ(entryFromBuilder.getKey(), index);
729TEST(LoanTests, OptionalFieldsReturnNullopt)
746 previousTxnLgrSeqValue,
753 paymentIntervalValue,
757 auto const entry = builder.build(index);
760 EXPECT_FALSE(entry.hasLoanOriginationFee());
761 EXPECT_FALSE(entry.getLoanOriginationFee().has_value());
762 EXPECT_FALSE(entry.hasLoanServiceFee());
763 EXPECT_FALSE(entry.getLoanServiceFee().has_value());
764 EXPECT_FALSE(entry.hasLatePaymentFee());
765 EXPECT_FALSE(entry.getLatePaymentFee().has_value());
766 EXPECT_FALSE(entry.hasClosePaymentFee());
767 EXPECT_FALSE(entry.getClosePaymentFee().has_value());
768 EXPECT_FALSE(entry.hasOverpaymentFee());
769 EXPECT_FALSE(entry.getOverpaymentFee().has_value());
770 EXPECT_FALSE(entry.hasInterestRate());
771 EXPECT_FALSE(entry.getInterestRate().has_value());
772 EXPECT_FALSE(entry.hasLateInterestRate());
773 EXPECT_FALSE(entry.getLateInterestRate().has_value());
774 EXPECT_FALSE(entry.hasCloseInterestRate());
775 EXPECT_FALSE(entry.getCloseInterestRate().has_value());
776 EXPECT_FALSE(entry.hasOverpaymentInterestRate());
777 EXPECT_FALSE(entry.getOverpaymentInterestRate().has_value());
778 EXPECT_FALSE(entry.hasGracePeriod());
779 EXPECT_FALSE(entry.getGracePeriod().has_value());
780 EXPECT_FALSE(entry.hasPreviousPaymentDueDate());
781 EXPECT_FALSE(entry.getPreviousPaymentDueDate().has_value());
782 EXPECT_FALSE(entry.hasNextPaymentDueDate());
783 EXPECT_FALSE(entry.getNextPaymentDueDate().has_value());
784 EXPECT_FALSE(entry.hasPaymentRemaining());
785 EXPECT_FALSE(entry.getPaymentRemaining().has_value());
786 EXPECT_FALSE(entry.hasPrincipalOutstanding());
787 EXPECT_FALSE(entry.getPrincipalOutstanding().has_value());
788 EXPECT_FALSE(entry.hasTotalValueOutstanding());
789 EXPECT_FALSE(entry.getTotalValueOutstanding().has_value());
790 EXPECT_FALSE(entry.hasManagementFeeOutstanding());
791 EXPECT_FALSE(entry.getManagementFeeOutstanding().has_value());
792 EXPECT_FALSE(entry.hasLoanScale());
793 EXPECT_FALSE(entry.getLoanScale().has_value());