@Test
void invest() {

    final ControlApi control = mock(ControlApi.class);
    final Api<ControlApi> ca = mockApi(control);
    final PaginatedApi<LoanImpl, LoanApi> la = mockApi();
    final int loanId = 1;
    final Loan loan = mock(LoanImpl.class);
    when(loan.getId()).thenReturn(loanId);
    when(loan.getAmount()).thenReturn(Money.from(200.0));
    when(loan.getRemainingInvestment()).thenReturn(Money.from(200.0));
    when(la.execute(any())).thenReturn(loan);
    final Zonky z = mockZonky(ca, la);
    final Loan l = z.getLoan(loanId);
    assertThat(z.invest(l, 200)).isEqualTo(InvestmentResult.success());
}