use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class PrimaryMarketplaceComparatorTest method sortByRecency.
@Test
void sortByRecency() {
final OffsetDateTime first = OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID);
final OffsetDateTime second = first.plus(Duration.ofMillis(1));
final Loan l1 = mockLoan(1, 100000, first);
final Loan l2 = mockLoan(l1.getId() + 1, l1.getAmount(), second);
final LoanDescriptor ld1 = new LoanDescriptor(l1), ld2 = new LoanDescriptor(l2);
assertSoftly(softly -> {
softly.assertThat(c.compare(ld1, ld2)).isEqualTo(1);
softly.assertThat(c.compare(ld2, ld1)).isEqualTo(-1);
softly.assertThat(c.compare(ld1, ld1)).isEqualTo(0);
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class PrimaryMarketplaceComparatorTest method sortByRemainingIfAsRecent.
@Test
void sortByRemainingIfAsRecent() {
final OffsetDateTime first = OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID);
final Loan l1 = mockLoan(1, 100000, first);
final Loan l2 = mockLoan(l1.getId() + 1, l1.getAmount() + 1, l1.getDatePublished());
final LoanDescriptor ld1 = new LoanDescriptor(l1), ld2 = new LoanDescriptor(l2);
assertSoftly(softly -> {
softly.assertThat(c.compare(ld1, ld2)).isEqualTo(1);
softly.assertThat(c.compare(ld2, ld1)).isEqualTo(-1);
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class WrapperTest method fromInvestment.
@Test
void fromInvestment() {
final Loan loan = Loan.custom().setId(1).setAmount(100_000).build();
final int invested = 200;
final Investment investment = Investment.fresh((MarketplaceLoan) loan, invested).build();
final Wrapper w = new Wrapper(investment, loan);
assertSoftly(softly -> {
softly.assertThat(w.getLoanId()).isEqualTo(loan.getId());
softly.assertThat(w.getStory()).isEqualTo(loan.getStory());
softly.assertThat(w.getRegion()).isEqualTo(loan.getRegion());
softly.assertThat(w.getRating()).isEqualTo(loan.getRating());
softly.assertThat(w.getOriginalAmount()).isEqualTo(loan.getAmount());
softly.assertThat(w.getInterestRate()).isEqualTo(loan.getInterestRate());
softly.assertThat(w.getRemainingTermInMonths()).isEqualTo(investment.getRemainingMonths());
softly.assertThat(w.getRemainingAmount()).isEqualTo(BigDecimal.valueOf(invested));
softly.assertThat(w.getIdentifier()).isNotNull();
});
}
Aggregations