LoanWrapper extends AbstractWrapper<LoanDescriptor> { @Override public Ratio getRevenueRate() { return loan.getRevenueRate() .orElseGet(this::estimateRevenueRate); } LoanWrapper(final LoanDescriptor original, final PortfolioOverview portfolioOverview); @Override long getId(); @Override boolean isInsuranceActive(); @Override Region getRegion(); @Override String getStory(); @Override MainIncomeType getMainIncomeType(); @Override Ratio getInterestRate(); @Override Ratio getRevenueRate(); @Override Purpose getPurpose(); @Override Rating getRating(); @Override int getOriginalTermInMonths(); @Override int getRemainingTermInMonths(); @Override int getOriginalAmount(); @Override int getOriginalAnnuity(); @Override OptionalInt getCurrentDpd(); @Override OptionalInt getLongestDpd(); @Override OptionalInt getDaysSinceDpd(); @Override BigDecimal getRemainingPrincipal(); @Override String toString();  }
@Test void fromLoanWithoutRevenueRate() { final LoanImpl loan = new MockLoanBuilder() .set(LoanImpl::setRating, Rating.D) .set(LoanImpl::setRevenueRate, null) .build(); final Wrapper<LoanDescriptor> w = Wrapper.wrap(new LoanDescriptor(loan), FOLIO); when(FOLIO.getInvested()).thenReturn(Money.ZERO); assertThat(w.getRevenueRate()).isEqualTo(Ratio.fromPercentage("14.99")); }