use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class LoanDescriptorTest method equalsSelf.
@Test
void equalsSelf() {
final Loan mockedLoan = LoanDescriptorTest.mockLoan();
final LoanDescriptor ld = new LoanDescriptor(mockedLoan);
assertThat(ld).isNotEqualTo(null).isEqualTo(ld);
final LoanDescriptor ld2 = new LoanDescriptor(mockedLoan);
assertThat(ld).isEqualTo(ld2);
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class LoanDescriptorTest method recommendWrongAmount.
@Test
void recommendWrongAmount() {
final Loan mockedLoan = LoanDescriptorTest.mockLoan();
final LoanDescriptor ld = new LoanDescriptor(mockedLoan);
final Optional<RecommendedLoan> r = ld.recommend(BigDecimal.valueOf(Defaults.MINIMUM_INVESTMENT_IN_CZK - 1));
assertThat(r).isEmpty();
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class LoanDescriptorTest method constructorForCaptcha.
@Disabled("Looks like CAPTCHA is disabled for now. Let's wait and see if it comes back.")
@Test
void constructorForCaptcha() {
final Loan mockedLoan = LoanDescriptorTest.mockLoan();
final LoanDescriptor ld = new LoanDescriptor(mockedLoan);
assertSoftly(softly -> {
softly.assertThat(ld.item()).isSameAs(mockedLoan);
softly.assertThat(ld.getLoanCaptchaProtectionEndDateTime()).isPresent().contains(mockedLoan.getDatePublished().plus(Settings.INSTANCE.getCaptchaDelay()));
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan 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.entities.sanitized.Loan in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentRejected.
private DynamicTest getParametersForInvestmentRejected() {
final Loan l = mockLoan();
final LoanDescriptor ld = new LoanDescriptor(l);
final RecommendedLoan r = ld.recommend(200).get();
final Event evt = new InvestmentRejectedEvent(r, "");
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getRejectedInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getRejectedInvestments()).containsOnlyKeys(l.getId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
Aggregations