@Test public void missingRepaymentInfoThrows() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("RepaymentInformation missing."); CreditDraft draft = CreditDataTestUtils.creditDraftTestBuilder() .status(IN_REPAYMENT) .creditRepaymentInfo(Option.none()) .build(); mapper.apply(draft); }
@NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new IllegalStateException(TAG + ": RepaymentInformation missing.")); return InRepaymentCardViewEntity.builder() .id(draft.id()) .title(draft.purpose()) .formattedAmount(currencyUtils.formatAmount(draft.amount())) .nextPaymentLabel(mapToNextPaymentLabel(repaymentInfo.totalPaid())) .formattedPaidOutDate(mapToFormattedPaidOutDate(repaymentInfo.disbursedDate())) .formattedTotalRepaid(currencyUtils.formatAmount(repaymentInfo.totalPaid())) .formattedNextPayment(mapToNextPaymentInfo(repaymentInfo.nextPayment(), repaymentInfo.nextPaymentDate())) .build(); }
InRepaymentCardViewEntityMapper implements Function<CreditDraft, InRepaymentCardViewEntity> { @NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new IllegalStateException(TAG + ": RepaymentInformation missing.")); return InRepaymentCardViewEntity.builder() .id(draft.id()) .title(draft.purpose()) .formattedAmount(currencyUtils.formatAmount(draft.amount())) .nextPaymentLabel(mapToNextPaymentLabel(repaymentInfo.totalPaid())) .formattedPaidOutDate(mapToFormattedPaidOutDate(repaymentInfo.disbursedDate())) .formattedTotalRepaid(currencyUtils.formatAmount(repaymentInfo.totalPaid())) .formattedNextPayment(mapToNextPaymentInfo(repaymentInfo.nextPayment(), repaymentInfo.nextPaymentDate())) .build(); } }
InRepaymentCardViewEntityMapper implements Function<CreditDraft, InRepaymentCardViewEntity> { @NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new IllegalStateException(TAG + ": RepaymentInformation missing.")); return InRepaymentCardViewEntity.builder() .id(draft.id()) .title(draft.purpose()) .formattedAmount(currencyUtils.formatAmount(draft.amount())) .nextPaymentLabel(mapToNextPaymentLabel(repaymentInfo.totalPaid())) .formattedPaidOutDate(mapToFormattedPaidOutDate(repaymentInfo.disbursedDate())) .formattedTotalRepaid(currencyUtils.formatAmount(repaymentInfo.totalPaid())) .formattedNextPayment(mapToNextPaymentInfo(repaymentInfo.nextPayment(), repaymentInfo.nextPaymentDate())) .build(); } @Inject  InRepaymentCardViewEntityMapper(@NonNull final StringProvider stringProvider,
                                    @NonNull final TimeUtils timeUtils,
                                    @NonNull final CurrencyUtils currencyUtils); }
InRepaymentCardViewEntityMapper implements Function<CreditDraft, InRepaymentCardViewEntity> { @NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new IllegalStateException(TAG + ": RepaymentInformation missing.")); return InRepaymentCardViewEntity.builder() .id(draft.id()) .title(draft.purpose()) .formattedAmount(currencyUtils.formatAmount(draft.amount())) .nextPaymentLabel(mapToNextPaymentLabel(repaymentInfo.totalPaid())) .formattedPaidOutDate(mapToFormattedPaidOutDate(repaymentInfo.disbursedDate())) .formattedTotalRepaid(currencyUtils.formatAmount(repaymentInfo.totalPaid())) .formattedNextPayment(mapToNextPaymentInfo(repaymentInfo.nextPayment(), repaymentInfo.nextPaymentDate())) .build(); } @Inject  InRepaymentCardViewEntityMapper(@NonNull final StringProvider stringProvider,
                                    @NonNull final TimeUtils timeUtils,
                                    @NonNull final CurrencyUtils currencyUtils); @NonNull InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft); }
InRepaymentCardViewEntityMapper implements Function<CreditDraft, InRepaymentCardViewEntity> { @NonNull public InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft) throws Exception { assertCorrectStatus(draft.status()); final CreditRepaymentInfo repaymentInfo = orThrowUnsafe(draft.creditRepaymentInfo(), new IllegalStateException(TAG + ": RepaymentInformation missing.")); return InRepaymentCardViewEntity.builder() .id(draft.id()) .title(draft.purpose()) .formattedAmount(currencyUtils.formatAmount(draft.amount())) .nextPaymentLabel(mapToNextPaymentLabel(repaymentInfo.totalPaid())) .formattedPaidOutDate(mapToFormattedPaidOutDate(repaymentInfo.disbursedDate())) .formattedTotalRepaid(currencyUtils.formatAmount(repaymentInfo.totalPaid())) .formattedNextPayment(mapToNextPaymentInfo(repaymentInfo.nextPayment(), repaymentInfo.nextPaymentDate())) .build(); } @Inject  InRepaymentCardViewEntityMapper(@NonNull final StringProvider stringProvider,
                                    @NonNull final TimeUtils timeUtils,
                                    @NonNull final CurrencyUtils currencyUtils); @NonNull InRepaymentCardViewEntity apply(@NonNull final CreditDraft draft);  }