@Override public BigDecimal getRecommendation() { return recommendation.amount(); }
@Override public BigDecimal getRecommendation() { return recommendation.amount(); }
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 InvestmentSkippedEventImpl(final RecommendedLoan recommendation) { this.loan = recommendation.descriptor().item(); this.recommendation = recommendation.amount(); }
private static Either<InvestmentFailure, BigDecimal> invest(final Tenant auth, final RecommendedLoan recommendedLoan) { LOGGER.debug("Executing investment: {}.", recommendedLoan); final Investment i = convertToInvestment(recommendedLoan); try { auth.run(zonky -> zonky.invest(i)); LOGGER.info("Invested {} CZK into loan #{}.", recommendedLoan.amount(), i.getLoanId()); return Either.right(recommendedLoan.amount()); } catch (final Exception ex) { LOGGER.debug("Failed investing {} CZK into loan #{}. Likely already full in the meantime.", recommendedLoan.amount(), i.getLoanId(), ex); return Either.left(InvestmentFailure.FAILED); } }
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(); }
private static Either<InvestmentFailure, BigDecimal> invest(final Tenant auth, final RecommendedLoan recommendedLoan) { LOGGER.debug("Executing investment: {}.", recommendedLoan); final Investment i = convertToInvestment(recommendedLoan); try { auth.run(zonky -> zonky.invest(i)); LOGGER.debug("Investment succeeded."); return Either.right(recommendedLoan.amount()); } catch (final Exception ex) { LOGGER.debug("Failed investing {} CZK into loan #{}. Likely already full in the meantime.", recommendedLoan.amount(), i.getLoanId(), ex); return Either.left(InvestmentFailure.FAILED); } }
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); } }
@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(); }); }