Search in sources :

Example 1 with MyInvestment

use of com.github.robozonky.api.remote.entities.MyInvestment in project robozonky by RoboZonky.

the class AbstractZonkyLeveragingTest method mockMyInvestment.

protected static MyInvestment mockMyInvestment(final OffsetDateTime creationDate) {
    final MyInvestment m = mock(MyInvestment.class);
    when(m.getTimeCreated()).thenReturn(creationDate);
    return m;
}
Also used : MyInvestment(com.github.robozonky.api.remote.entities.MyInvestment)

Example 2 with MyInvestment

use of com.github.robozonky.api.remote.entities.MyInvestment in project robozonky by RoboZonky.

the class LoanCacheTest method emptyGetLoan.

@Test
void emptyGetLoan() {
    final LoanCache c = new LoanCache();
    final int loanId = 1;
    // nothing returned at first
    assertThat(c.getLoan(loanId)).isEmpty();
    final MyInvestment mi = mock(MyInvestment.class);
    when(mi.getTimeCreated()).thenReturn(OffsetDateTime.now());
    final Loan loan = Loan.custom().setId(loanId).setMyInvestment(mi).build();
    final Zonky z = harmlessZonky(10_000);
    when(z.getLoan(eq(loanId))).thenReturn(loan);
    // return the freshly retrieved loan
    assertThat(c.getLoan(loanId, z)).isEqualTo(loan);
    final Investment i = Investment.custom().setLoanId(loanId).build();
    assertThat(c.getLoan(i, z)).isEqualTo(loan);
    assertThat(i.getInvestmentDate()).isNotEmpty();
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MyInvestment(com.github.robozonky.api.remote.entities.MyInvestment) Zonky(com.github.robozonky.common.remote.Zonky) MyInvestment(com.github.robozonky.api.remote.entities.MyInvestment) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) Test(org.junit.jupiter.api.Test) AbstractZonkyLeveragingTest(com.github.robozonky.app.AbstractZonkyLeveragingTest)

Example 3 with MyInvestment

use of com.github.robozonky.api.remote.entities.MyInvestment in project robozonky by RoboZonky.

the class FinancialCalculatorTest method mockLoan.

private static Loan mockLoan(final Rating rating) {
    final MyInvestment investment = Mockito.mock(MyInvestment.class);
    Mockito.when(investment.getTimeCreated()).thenReturn(OffsetDateTime.now());
    return Loan.custom().setId(1).setAmount(100_000).setMyInvestment(investment).setRating(rating).setTermInMonths(84).build();
}
Also used : MyInvestment(com.github.robozonky.api.remote.entities.MyInvestment)

Aggregations

MyInvestment (com.github.robozonky.api.remote.entities.MyInvestment)3 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)1 Loan (com.github.robozonky.api.remote.entities.sanitized.Loan)1 AbstractZonkyLeveragingTest (com.github.robozonky.app.AbstractZonkyLeveragingTest)1 Zonky (com.github.robozonky.common.remote.Zonky)1 Test (org.junit.jupiter.api.Test)1