use of com.github.robozonky.api.remote.ParticipationApi 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();
}
use of com.github.robozonky.api.remote.ParticipationApi in project robozonky by RoboZonky.
the class ZonkyTest method sell.
@Test
void sell() {
final ControlApi control = mock(ControlApi.class);
final Api<ControlApi> ca = mockApi(control);
final PaginatedApi<RawLoan, LoanApi> la = mockApi();
final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
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 Investment p = Investment.custom().setRemainingPrincipal(BigDecimal.TEN).setSmpFee(BigDecimal.ONE).setId(1).build();
z.sell(p);
verify(control).offer(any());
}
use of com.github.robozonky.api.remote.ParticipationApi in project robozonky by RoboZonky.
the class ZonkyTest method investAndlogout.
@Test
void investAndlogout() {
final ControlApi control = mock(ControlApi.class);
final Api<ControlApi> ca = mockApi(control);
final PaginatedApi<RawLoan, LoanApi> la = mockApi();
final int loanId = 1;
final RawLoan loan = mock(RawLoan.class);
when(loan.getId()).thenReturn(loanId);
when(loan.getAmount()).thenReturn(200.0);
when(loan.getRemainingInvestment()).thenReturn(200.0);
when(la.execute((Function<LoanApi, RawLoan>) any())).thenReturn(loan);
final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
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 Loan l = z.getLoan(loanId);
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
z.invest(i);
z.logout();
verify(control, times(1)).invest(any());
verify(control, times(1)).logout();
}
use of com.github.robozonky.api.remote.ParticipationApi in project robozonky by RoboZonky.
the class ZonkyTest method purchase.
@Test
void purchase() {
final ControlApi control = mock(ControlApi.class);
final Api<ControlApi> ca = mockApi(control);
final PaginatedApi<RawLoan, LoanApi> la = mockApi();
final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
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 Participation p = mock(Participation.class);
when(p.getRemainingPrincipal()).thenReturn(BigDecimal.TEN);
when(p.getId()).thenReturn(1);
z.purchase(p);
verify(control).purchase(eq(p.getId()), any());
}
use of com.github.robozonky.api.remote.ParticipationApi in project robozonky by RoboZonky.
the class ZonkyTest method cancel.
@Test
void cancel() {
final ControlApi control = mock(ControlApi.class);
final Api<ControlApi> ca = mockApi(control);
final PaginatedApi<RawLoan, LoanApi> la = mockApi();
final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
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 Investment i = mock(Investment.class);
when(i.getId()).thenReturn(1);
z.cancel(i);
verify(control).cancel(eq(i.getId()));
}
Aggregations