use of com.github.robozonky.api.remote.entities.BlockedAmount in project robozonky by RoboZonky.
the class Session method markSuccessfulInvestment.
private void markSuccessfulInvestment(final Investment i) {
investmentsMadeNow.add(i);
loansStillAvailable.removeIf(l -> isSameLoan(l, i));
final BlockedAmount b = new BlockedAmount(i.getLoanId(), i.getOriginalPrincipal(), TransactionCategory.INVESTMENT);
portfolio.newBlockedAmount(authenticated, b);
portfolio.getRemoteBalance().update(i.getOriginalPrincipal().negate());
portfolioOverview = portfolio.calculateOverview();
}
use of com.github.robozonky.api.remote.entities.BlockedAmount in project robozonky by RoboZonky.
the class Session method markSuccessfulPurchase.
private void markSuccessfulPurchase(final Investment i) {
investmentsMadeNow.add(i);
final int id = i.getLoanId();
stillAvailable.removeIf(l -> l.item().getLoanId() == id);
portfolio.newBlockedAmount(authenticated, new BlockedAmount(id, i.getOriginalPrincipal(), TransactionCategory.SMP_BUY));
portfolio.getRemoteBalance().update(i.getOriginalPrincipal().negate());
portfolioOverview = portfolio.calculateOverview();
}
use of com.github.robozonky.api.remote.entities.BlockedAmount in project robozonky by RoboZonky.
the class BlockedAmountsTest method newBlockedAmounts.
@Test
void newBlockedAmounts() {
final Zonky zonky = harmlessZonky(10_000);
when(zonky.getBlockedAmounts()).thenReturn(Stream.of(BA1, BA2));
final Authenticated auth = mockAuthentication(zonky);
final Portfolio p = mock(Portfolio.class);
final BlockedAmounts blockedAmounts = new BlockedAmounts();
// verify the first two blocked amounts were registered
blockedAmounts.accept(p, auth);
verify(p).newBlockedAmount(eq(auth), eq(BA1));
verify(p).newBlockedAmount(eq(auth), eq(BA2));
// verify only the new blocked amount was registered, and that it only happened the first time
reset(p);
when(zonky.getBlockedAmounts()).thenAnswer((Answer<Stream<BlockedAmount>>) invocation -> Stream.of(BA1, BA2, BA3));
blockedAmounts.accept(p, auth);
blockedAmounts.accept(p, auth);
verify(p, times(1)).newBlockedAmount(eq(auth), eq(BA3));
}
use of com.github.robozonky.api.remote.entities.BlockedAmount 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.entities.BlockedAmount 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