@Test void loan() { 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(any())).thenReturn(loan); final ApiProvider p = spy(new ApiProvider()); when(p.marketplace(any())).thenReturn(la); final Zonky z = new Zonky(p, () -> mock(ZonkyApiToken.class)); assertThat(z.getLoan(loanId).getId()).isEqualTo(loanId); }
@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(any())).thenReturn(loan); final Zonky z = mockZonky(ca, la); final Loan l = z.getLoan(loanId); final Investment i = Investment.fresh(l, 200); z.invest(i); z.logout(); verify(control, times(1)).invest(any()); verify(control, times(1)).logout(); }
this.rating = original.getRating(); this.region = original.getRegion(); this.remainingInvestment = (int) original.getRemainingInvestment(); this.nonReservedRemainingInvestment = (int) (original.getRemainingInvestment() - original.getReservedAmount()); this.story = original.getStory(); this.termInMonths = original.getTermInMonths();
this.rating = original.getRating(); this.region = original.getRegion(); this.remainingInvestment = (int) original.getRemainingInvestment(); this.nonReservedRemainingInvestment = (int)(original.getRemainingInvestment() - original.getReservedAmount()); this.story = original.getStory(); this.termInMonths = original.getTermInMonths();