use of com.github.robozonky.api.strategies.RecommendedLoan 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);
}
use of com.github.robozonky.api.strategies.RecommendedLoan in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentDelegated.
private DynamicTest getParametersForInvestmentDelegated() {
final Loan l = mockLoan();
final LoanDescriptor ld = new LoanDescriptor(l);
final RecommendedLoan r = ld.recommend(200).get();
final Event evt = new InvestmentDelegatedEvent(r, "");
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getDelegatedInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getDelegatedInvestments()).containsOnlyKeys(l.getId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
use of com.github.robozonky.api.strategies.RecommendedLoan in project robozonky by RoboZonky.
the class SessionTest method investmentDelegatedButExpectedConfirmed.
@Test
void investmentDelegatedButExpectedConfirmed() {
final LoanDescriptor ld = AbstractZonkyLeveragingTest.mockLoanDescriptor();
final RecommendedLoan r = ld.recommend(200, true).get();
final Collection<LoanDescriptor> availableLoans = Collections.singletonList(ld);
final Zonky z = AbstractZonkyLeveragingTest.harmlessZonky(10_000);
final Authenticated auth = mockAuthentication(z);
final Investor p = mock(Investor.class);
doReturn(new ZonkyResponse(ZonkyResponseType.DELEGATED)).when(p).invest(eq(r), anyBoolean());
doReturn(Optional.of("something")).when(p).getConfirmationProviderId();
final Portfolio portfolio = Portfolio.create(z, mockBalance(z));
final Session t = new Session(portfolio, new LinkedHashSet<>(availableLoans), p, auth);
final boolean result = t.invest(r);
assertThat(result).isFalse();
// validate event
final List<Event> newEvents = this.getNewEvents();
assertThat(newEvents).hasSize(2);
assertSoftly(softly -> {
softly.assertThat(newEvents.get(0)).isInstanceOf(InvestmentRequestedEvent.class);
softly.assertThat(newEvents.get(1)).isInstanceOf(InvestmentDelegatedEvent.class);
});
}
use of com.github.robozonky.api.strategies.RecommendedLoan in project robozonky by RoboZonky.
the class SessionTest method investmentRejected.
@Test
void investmentRejected() {
final Zonky z = AbstractZonkyLeveragingTest.harmlessZonky(10_000);
final Authenticated auth = mockAuthentication(z);
final RecommendedLoan r = AbstractZonkyLeveragingTest.mockLoanDescriptor().recommend(200).get();
final Investor p = mock(Investor.class);
doReturn(new ZonkyResponse(ZonkyResponseType.REJECTED)).when(p).invest(eq(r), anyBoolean());
doReturn(Optional.of("something")).when(p).getConfirmationProviderId();
final Portfolio portfolio = Portfolio.create(z, mockBalance(z));
final Session t = new Session(portfolio, Collections.emptySet(), p, auth);
final boolean result = t.invest(r);
assertThat(result).isFalse();
// validate event
final List<Event> newEvents = this.getNewEvents();
assertThat(newEvents).hasSize(2);
assertSoftly(softly -> {
softly.assertThat(newEvents.get(0)).isInstanceOf(InvestmentRequestedEvent.class);
softly.assertThat(newEvents.get(1)).isInstanceOf(InvestmentRejectedEvent.class);
});
}
use of com.github.robozonky.api.strategies.RecommendedLoan in project robozonky by RoboZonky.
the class SessionTest method investmentDelegated.
@Test
void investmentDelegated() {
final LoanDescriptor ld = AbstractZonkyLeveragingTest.mockLoanDescriptor();
final RecommendedLoan r = ld.recommend(200).get();
final Zonky z = AbstractZonkyLeveragingTest.harmlessZonky(10_000);
final Authenticated auth = mockAuthentication(z);
final Investor p = mock(Investor.class);
doReturn(new ZonkyResponse(ZonkyResponseType.DELEGATED)).when(p).invest(eq(r), anyBoolean());
doReturn(Optional.of("something")).when(p).getConfirmationProviderId();
final Collection<LoanDescriptor> availableLoans = Collections.singletonList(ld);
final Portfolio portfolio = Portfolio.create(z, mockBalance(z));
final Session t = new Session(portfolio, new LinkedHashSet<>(availableLoans), p, auth);
final boolean result = t.invest(r);
assertThat(result).isFalse();
// validate event
final List<Event> newEvents = this.getNewEvents();
assertThat(newEvents).hasSize(2);
assertSoftly(softly -> {
softly.assertThat(newEvents.get(0)).isInstanceOf(InvestmentRequestedEvent.class);
softly.assertThat(newEvents.get(1)).isInstanceOf(InvestmentDelegatedEvent.class);
});
}
Aggregations