Search in sources :

Example 51 with Loan

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);
    });
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) OffsetDateTime(java.time.OffsetDateTime) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) Test(org.junit.jupiter.api.Test)

Example 52 with Loan

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);
    });
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) OffsetDateTime(java.time.OffsetDateTime) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) Test(org.junit.jupiter.api.Test)

Example 53 with Loan

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();
    });
}
Also used : MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) Test(org.junit.jupiter.api.Test)

Aggregations

Loan (com.github.robozonky.api.remote.entities.sanitized.Loan)53 Test (org.junit.jupiter.api.Test)46 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)25 LoanDescriptor (com.github.robozonky.api.strategies.LoanDescriptor)20 AbstractZonkyLeveragingTest (com.github.robozonky.app.AbstractZonkyLeveragingTest)19 MarketplaceLoan (com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan)14 Zonky (com.github.robozonky.common.remote.Zonky)14 SoftAssertions (org.assertj.core.api.SoftAssertions)14 PortfolioOverview (com.github.robozonky.api.strategies.PortfolioOverview)13 Assertions (org.assertj.core.api.Assertions)13 Mockito (org.mockito.Mockito)13 Event (com.github.robozonky.api.notifications.Event)12 Portfolio (com.github.robozonky.app.portfolio.Portfolio)12 Authenticated (com.github.robozonky.app.authentication.Authenticated)11 Collection (java.util.Collection)11 Collections (java.util.Collections)11 Stream (java.util.stream.Stream)10 Optional (java.util.Optional)9 InvestmentPurchasedEvent (com.github.robozonky.api.notifications.InvestmentPurchasedEvent)8 Participation (com.github.robozonky.api.remote.entities.Participation)8