Zonky { public void sell(final Investment investment) { SellRequest request = new SellRequest(investment); LOGGER.debug("Offering to sell investment in loan #{} ({}).", investment.getLoan() .getId(), request); controlApi.run(api -> api.offer(request)); } Zonky(final ApiProvider api, final Supplier<ZonkyApiToken> tokenSupplier); InvestmentResult invest(final Loan loan, final int amount); void cancel(final Investment investment); PurchaseResult purchase(final Participation participation); void sell(final Investment investment); void accept(final Reservation reservation); Stream<Reservation> getPendingReservations(); Stream<Investment> getInvestments(final Select select); Stream<Investment> getPendingInvestments(); Stream<Investment> getSoldInvestments(); Stream<Investment> getSellableInvestments(); Stream<Investment> getDelinquentInvestments(); Loan getLoan(final int id); Investment getInvestment(final long id); LastPublishedItem getLastPublishedLoanInfo(); LastPublishedItem getLastPublishedParticipationInfo(); ParticipationDetail getParticipationDetail(final int loanId); Stream<Loan> getAvailableLoans(final Select select); Stream<Participation> getAvailableParticipations(final Select select); ReservationPreferences getReservationPreferences(); void setReservationPreferences(final ReservationPreferencesImpl preferences); Restrictions getRestrictions(); Consents getConsents(); Statistics getStatistics();  }
@Test void sell() { final ControlApi control = mock(ControlApi.class); final Api<ControlApi> ca = mockApi(control); final Zonky z = mockZonkyControl(ca); final LoanImpl loan = new LoanImpl(); loan.setRating(Rating.D); final InvestmentImpl investment = new InvestmentImpl(new InvestmentLoanDataImpl(loan), Money.from(200)); investment.setId(1); investment.setPrincipal(new AmountsImpl(Money.from(10))); final SellInfoImpl sellInfo = new SellInfoImpl(Money.from(10), Money.from(1)); investment.setSmpSellInfo(sellInfo); z.sell(investment); verify(control).offer(any()); }