public InvestmentRejectedEventImpl(final RecommendedLoan recommendation, final String confirmationProviderId) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); this.confirmationProviderId = confirmationProviderId; }
public InvestmentSkippedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
public InvestmentDelegatedEventImpl(final RecommendedLoan recommendation, final String confirmationProviderId) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); this.confirmationProviderId = confirmationProviderId; }
public InvestmentRejectedEventImpl(final RecommendedLoan recommendation, final String confirmationProviderId) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); this.confirmationProviderId = confirmationProviderId; }
public InvestmentDelegatedEventImpl(final RecommendedLoan recommendation, final String confirmationProviderId) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); this.confirmationProviderId = confirmationProviderId; }
public InvestmentRequestedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
public LoanRecommendedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
public LoanRecommendedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
public InvestmentRequestedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
public InvestmentSkippedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
static Investment convertToInvestment(final RecommendedLoan r) { final int amount = r.amount().intValue(); return Investment.fresh(r.descriptor().item(), amount); }
static Investment convertToInvestment(final RecommendedLoan r) { final int amount = r.amount().intValue(); return Investment.fresh(r.descriptor().item(), amount); }
private Either<InvestmentFailure, BigDecimal> delegateOrReject(final RecommendedLoan r) { LOGGER.debug("Asking to confirm investment: {}.", r); final boolean delegationSucceeded = this.provider.requestConfirmation(this.requestId, r.descriptor().item().getId(), r.amount().intValue()); if (delegationSucceeded) { LOGGER.debug("Investment confirmed delegated, not investing: {}.", r); return Either.left(InvestmentFailure.DELEGATED); } else { LOGGER.debug("Investment not confirmed delegated, not investing: {}.", r); return Either.left(InvestmentFailure.REJECTED); } }
private Either<InvestmentFailure, BigDecimal> delegateOrReject(final RecommendedLoan r) { LOGGER.debug("Asking to confirm investment: {}.", r); final boolean delegationSucceeded = this.provider.requestConfirmation(this.requestId, r.descriptor().item().getId(), r.amount().intValue()); if (delegationSucceeded) { LOGGER.debug("Investment confirmed delegated, not investing: {}.", r); return Either.left(InvestmentFailure.DELEGATED); } else { LOGGER.debug("Investment not confirmed delegated, not investing: {}.", r); return Either.left(InvestmentFailure.REJECTED); } }
private Either<InvestmentFailure, BigDecimal> investOrDelegateOnCaptcha(final RecommendedLoan r) { final Optional<OffsetDateTime> captchaEndDateTime = r.descriptor().getLoanCaptchaProtectionEndDateTime(); final boolean isCaptchaProtected = captchaEndDateTime.isPresent() && captchaEndDateTime.get().isAfter(DateUtil.offsetNow()); final boolean confirmationSupported = this.provider != null; if (!isCaptchaProtected) { return this.investLocallyFailingOnCaptcha(r); } else if (confirmationSupported) { return this.delegateOrReject(r); } LOGGER.warn("CAPTCHA protected, no support for delegation. Not investing: {}.", r); return Either.left(InvestmentFailure.REJECTED); }
private boolean successfulInvestment(final RecommendedLoan recommendation, final BigDecimal amount) { final int confirmedAmount = amount.intValue(); final MarketplaceLoan l = recommendation.descriptor().item(); final Investment i = Investment.fresh(l, confirmedAmount); markSuccessfulInvestment(i); discard(recommendation.descriptor()); // never show again tenant.fire(investmentMadeLazy(() -> investmentMade(i, l, tenant.getPortfolio().getOverview()))); return true; }
private boolean successfulInvestment(final RecommendedLoan recommendation, final BigDecimal amount) { final int confirmedAmount = amount.intValue(); final MarketplaceLoan l = recommendation.descriptor().item(); final Investment i = Investment.fresh(l, confirmedAmount); markSuccessfulInvestment(i); discard(recommendation.descriptor()); // never show again tenant.fire(investmentMadeLazy(() -> investmentMade(i, l, tenant.getPortfolio().getOverview()))); return true; }
@Test void underAmount() { final Zonky z = harmlessZonky(0); final PowerTenant auth = mockTenant(z); final RecommendedLoan recommendation = mockLoanDescriptor().recommend(200).get(); final InvestingSession t = new InvestingSession(Collections.singleton(recommendation.descriptor()), getInvestor(auth), auth); final boolean result = t.invest(recommendation); // verify result assertThat(result).isFalse(); final List<Event> newEvents = getEventsRequested(); assertThat(newEvents).isEmpty(); }
@Test void recommendAmount() { final Loan mockedLoan = LoanDescriptorTest.mockLoan(); final LoanDescriptor ld = new LoanDescriptor(mockedLoan); final Optional<RecommendedLoan> r = ld.recommend(200); assertThat(r).isPresent(); final RecommendedLoan recommendation = r.get(); assertSoftly(softly -> { softly.assertThat(recommendation.descriptor()).isSameAs(ld); softly.assertThat(recommendation.amount()).isEqualTo(BigDecimal.valueOf(200)); softly.assertThat(recommendation.isConfirmationRequired()).isFalse(); }); }
@Test void constructor() { final LoanDescriptor ld = RecommendedLoanTest.mockLoanDescriptor(); final int amount = 200; final RecommendedLoan r = new RecommendedLoan(ld, amount, true); SoftAssertions.assertSoftly(softly -> { softly.assertThat(r.descriptor()).isSameAs(ld); softly.assertThat(r.amount()).isEqualTo(BigDecimal.valueOf(amount)); softly.assertThat(r.isConfirmationRequired()).isTrue(); }); }