@Override public int getRemainingTermInMonths() { return participation.getRemainingInstalmentCount(); }
@Override public int getRemainingTermInMonths() { return participation.getRemainingInstalmentCount(); }
private static ParticipationDescriptor mockParticipationDescriptor(final Loan loan) { final Participation p = mock(Participation.class); doReturn(loan.getTermInMonths()).when(p).getRemainingInstalmentCount(); return new ParticipationDescriptor(p, () -> loan); }
private static ParticipationDescriptor mockParticipationDescriptor(final Loan loan, final int remainingInstalments, final OffsetDateTime deadline) { final Participation p = mock(Participation.class); when(p.getRemainingInstalmentCount()).thenReturn(remainingInstalments); when(p.getDeadline()).thenReturn(deadline); when(p.getRemainingPrincipal()).thenReturn(BigDecimal.valueOf(loan.getAmount())); return new ParticipationDescriptor(p, () -> loan); }
static Investment fresh(final Participation participation, final Loan loan, final BigDecimal amount) { return Investment.fresh(loan, amount) .setId(participation.getInvestmentId()) .setRemainingMonths(participation.getRemainingInstalmentCount()) .setInvestmentDate(DateUtil.offsetNow()) .build(); }
static Investment fresh(final Participation participation, final Loan loan, final BigDecimal amount) { return Investment.fresh(loan, amount) .setId(participation.getInvestmentId()) .setRemainingMonths(participation.getRemainingInstalmentCount()) .setInvestmentDate(DateUtil.offsetNow()) .build(); }
@Test @DisplayName("Fresh from Participation works.") void freshFromParticipation() { final Loan l = Loan.custom().build(); final Participation p = mock(Participation.class); when(p.getInvestmentId()).thenReturn(1L); when(p.getRemainingInstalmentCount()).thenReturn(2); final Investment i = Investment.fresh(p, l, BigDecimal.valueOf(1000)); assertSoftly(softly -> { softly.assertThat(i.getRemainingPrincipal()).isEqualTo(BigDecimal.valueOf(1000)); softly.assertThat(i.getId()).isEqualTo(p.getInvestmentId()); softly.assertThat(i.getRemainingMonths()).isEqualTo(p.getRemainingInstalmentCount()); softly.assertThat(i.getInvestmentDate()).isBeforeOrEqualTo(OffsetDateTime.now()); }); }
@Test void values() { final ParticipationDescriptor original = new ParticipationDescriptor(PARTICIPATION, () -> LOAN); final Wrapper<ParticipationDescriptor> w = Wrapper.wrap(original); assertSoftly(softly -> { softly.assertThat(w.isInsuranceActive()).isEqualTo(PARTICIPATION.isInsuranceActive()); softly.assertThat(w.getInterestRate()).isEqualTo(PARTICIPATION.getInterestRate()); softly.assertThat(w.getRegion()).isEqualTo(LOAN.getRegion()); softly.assertThat(w.getRating()).isEqualTo(PARTICIPATION.getRating()); softly.assertThat(w.getMainIncomeType()).isEqualTo(LOAN.getMainIncomeType()); softly.assertThat(w.getPurpose()).isEqualTo(LOAN.getPurpose()); softly.assertThat(w.getOriginalAmount()).isEqualTo(LOAN.getAmount()); softly.assertThat(w.getRemainingPrincipal()).isEqualTo(PARTICIPATION.getRemainingPrincipal()); softly.assertThat(w.getOriginal()).isSameAs(original); softly.assertThat(w.getStory()).isEqualTo(LOAN.getStory()); softly.assertThat(w.getOriginalTermInMonths()).isEqualTo(PARTICIPATION.getOriginalInstalmentCount()); softly.assertThat(w.getRemainingTermInMonths()).isEqualTo(PARTICIPATION.getRemainingInstalmentCount()); softly.assertThat(w.toString()).isNotNull(); }); }