Search in sources :

Example 1 with Participation

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

the class ParticipationDescriptorTest method recommend.

@Test
void recommend() {
    final Participation p = ParticipationDescriptorTest.mockParticipation(BigDecimal.TEN);
    final ParticipationDescriptor pd = new ParticipationDescriptor(p);
    final Optional<RecommendedParticipation> r = pd.recommend(p.getRemainingPrincipal());
    assertThat(r).isPresent();
    assertSoftly(softly -> {
        softly.assertThat(r.get().amount()).isEqualTo(p.getRemainingPrincipal());
        softly.assertThat(r.get().descriptor()).isEqualTo(pd);
    });
}
Also used : Participation(com.github.robozonky.api.remote.entities.Participation) Test(org.junit.jupiter.api.Test)

Example 2 with Participation

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

the class ParticipationDescriptorTest method mockParticipation.

private static Participation mockParticipation(final BigDecimal amount) {
    final Participation p = mock(Participation.class);
    when(p.getRemainingPrincipal()).thenReturn(amount);
    return p;
}
Also used : Participation(com.github.robozonky.api.remote.entities.Participation)

Example 3 with Participation

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

the class ParticipationDescriptorTest method recommendWrong.

@Test
void recommendWrong() {
    final Participation p = ParticipationDescriptorTest.mockParticipation(BigDecimal.TEN);
    final ParticipationDescriptor pd = new ParticipationDescriptor(p);
    final Optional<RecommendedParticipation> r = pd.recommend(p.getRemainingPrincipal().subtract(BigDecimal.ONE));
    assertThat(r).isEmpty();
}
Also used : Participation(com.github.robozonky.api.remote.entities.Participation) Test(org.junit.jupiter.api.Test)

Example 4 with Participation

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

the class RecommendedParticipationTest method mockParticipation.

private static Participation mockParticipation() {
    final Participation p = mock(Participation.class);
    when(p.getRemainingPrincipal()).thenReturn(BigDecimal.TEN);
    return p;
}
Also used : Participation(com.github.robozonky.api.remote.entities.Participation)

Example 5 with Participation

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

the class ZonkyTest method wallet.

@Test
void wallet() {
    final ControlApi control = mock(ControlApi.class);
    final Api<ControlApi> ca = mockApi(control);
    final PaginatedApi<RawLoan, LoanApi> la = mockApi();
    final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
    when(wa.execute((Function<WalletApi, Wallet>) any())).thenReturn(mock(Wallet.class));
    final PaginatedApi<RawInvestment, PortfolioApi> pa = mockApi();
    final PaginatedApi<Participation, ParticipationApi> sa = mockApi();
    final PaginatedApi<RawDevelopment, CollectionsApi> caa = mockApi();
    final Zonky z = new Zonky(ca, la, sa, pa, wa, caa);
    final Wallet w = z.getWallet();
    assertThat(w).isNotNull();
}
Also used : Participation(com.github.robozonky.api.remote.entities.Participation) ParticipationApi(com.github.robozonky.api.remote.ParticipationApi) WalletApi(com.github.robozonky.api.remote.WalletApi) Wallet(com.github.robozonky.api.remote.entities.Wallet) LoanApi(com.github.robozonky.api.remote.LoanApi) PortfolioApi(com.github.robozonky.api.remote.PortfolioApi) BlockedAmount(com.github.robozonky.api.remote.entities.BlockedAmount) RawLoan(com.github.robozonky.api.remote.entities.RawLoan) ControlApi(com.github.robozonky.api.remote.ControlApi) RawDevelopment(com.github.robozonky.api.remote.entities.RawDevelopment) CollectionsApi(com.github.robozonky.api.remote.CollectionsApi) RawInvestment(com.github.robozonky.api.remote.entities.RawInvestment) Test(org.junit.jupiter.api.Test)

Aggregations

Participation (com.github.robozonky.api.remote.entities.Participation)24 Test (org.junit.jupiter.api.Test)18 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)8 Loan (com.github.robozonky.api.remote.entities.sanitized.Loan)8 PurchaseRequestedEvent (com.github.robozonky.api.notifications.PurchaseRequestedEvent)7 ParticipationDescriptor (com.github.robozonky.api.strategies.ParticipationDescriptor)7 Portfolio (com.github.robozonky.app.portfolio.Portfolio)7 Event (com.github.robozonky.api.notifications.Event)6 PurchaseStrategy (com.github.robozonky.api.strategies.PurchaseStrategy)6 AbstractZonkyLeveragingTest (com.github.robozonky.app.AbstractZonkyLeveragingTest)6 CollectionsApi (com.github.robozonky.api.remote.CollectionsApi)5 ControlApi (com.github.robozonky.api.remote.ControlApi)5 LoanApi (com.github.robozonky.api.remote.LoanApi)5 ParticipationApi (com.github.robozonky.api.remote.ParticipationApi)5 PortfolioApi (com.github.robozonky.api.remote.PortfolioApi)5 WalletApi (com.github.robozonky.api.remote.WalletApi)5 BlockedAmount (com.github.robozonky.api.remote.entities.BlockedAmount)5 RawDevelopment (com.github.robozonky.api.remote.entities.RawDevelopment)5 RawInvestment (com.github.robozonky.api.remote.entities.RawInvestment)5 RawLoan (com.github.robozonky.api.remote.entities.RawLoan)5