本文整理了Java中com.github.robozonky.common.remote.Zonky.getInvestmentByLoanId()
方法的一些代码示例,展示了Zonky.getInvestmentByLoanId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zonky.getInvestmentByLoanId()
方法的具体详情如下:
包路径:com.github.robozonky.common.remote.Zonky
类名称:Zonky
方法名:getInvestmentByLoanId
暂无
代码示例来源:origin: RoboZonky/robozonky
protected static Investment lookupOrFail(final int loanId, final Tenant auth) {
return auth.call(zonky -> zonky.getInvestmentByLoanId(loanId))
.orElseThrow(() -> new IllegalStateException("Investment not found for loan #" + loanId));
}
代码示例来源:origin: com.github.robozonky/robozonky-app
protected static Investment lookupOrFail(final int loanId, final Tenant auth) {
return auth.call(zonky -> zonky.getInvestmentByLoanId(loanId))
.orElseThrow(() -> new IllegalStateException("Investment not found for loan #" + loanId));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
public void queriesAndUpdatesWhenNewTransactionsFound() {
state.update(m -> m.put(IncomeProcessor.STATE_KEY, "1"));
final Loan l1 = Loan.custom().build();
final Transaction t1 = new Transaction(1, l1, BigDecimal.TEN, TransactionCategory.PAYMENT,
TransactionOrientation.IN);
final Loan l2 = Loan.custom().build();
final Transaction t2 = new Transaction(2, l2, BigDecimal.ONE, TransactionCategory.SMP_SELL,
TransactionOrientation.IN);
final Investment i2 = Investment.fresh(l2, BigDecimal.ONE).build();
final Loan l3 = Loan.custom().build();
final Investment i3 = Investment.fresh(l3, BigDecimal.TEN)
.setPaymentStatus(PaymentStatus.PAID)
.build();
final Transaction t3 = new Transaction(3, l3, BigDecimal.TEN, TransactionCategory.PAYMENT,
TransactionOrientation.IN);
when(zonky.getTransactions((Select) any())).thenAnswer(i -> Stream.of(t2, t3, t1));
when(zonky.getLoan(eq(l2.getId()))).thenReturn(l2);
when(zonky.getLoan(eq(l3.getId()))).thenReturn(l3);
when(zonky.getInvestmentByLoanId(eq(l2.getId()))).thenReturn(Optional.of(i2));
when(zonky.getInvestmentByLoanId(eq(l3.getId()))).thenReturn(Optional.of(i3));
processor.accept(tenant);
verify(zonky, times(1)).getTransactions((Select) any());
assertThat(state.getValue(IncomeProcessor.STATE_KEY)).hasValue("3"); // new maximum
assertThat(getEventsRequested()).hasSize(2);
}
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void correctlyGuessesInvestmentDateFromTransactionHistory() {
final Loan loan = Loan.custom()
.setId(1)
.build();
final Investment i = Investment.fresh(loan, 200)
.build();
final RawInvestment r = spy(new RawInvestment(i));
when(r.getInvestmentDate()).thenReturn(null); // enforce so that the date-guessing code has a chance to trigger
final PaginatedApi<RawInvestment, PortfolioApi> pa = mockApi(Collections.singletonList(r));
final Transaction irrelevant1 =
new Transaction(i, BigDecimal.ZERO, TransactionCategory.SMP_BUY, TransactionOrientation.OUT);
final Transaction irrelevant2 =
new Transaction(i, BigDecimal.ZERO, TransactionCategory.SMP_SELL, TransactionOrientation.IN);
final Transaction relevant =
new Transaction(i, BigDecimal.ZERO, TransactionCategory.PAYMENT, TransactionOrientation.IN);
final PaginatedApi<Transaction, TransactionApi> ta = mockApi(Arrays.asList(irrelevant1, relevant, irrelevant2));
final Zonky z = mockZonky(pa, ta);
final Optional<Investment> result = z.getInvestmentByLoanId(loan.getId());
assertThat(result).isPresent();
final Investment actual = result.get();
final LocalDate investmentDate = actual.getInvestmentDate().toLocalDate();
assertThat(investmentDate).isEqualTo(relevant.getTransactionDate().minusMonths(1));
}
内容来源于网络,如有侵权,请联系作者删除!