gpt4 book ai didi

com.github.robozonky.common.remote.Zonky.getTransactions()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 23:49:31 25 4
gpt4 key购买 nike

本文整理了Java中com.github.robozonky.common.remote.Zonky.getTransactions()方法的一些代码示例,展示了Zonky.getTransactions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zonky.getTransactions()方法的具体详情如下:
包路径:com.github.robozonky.common.remote.Zonky
类名称:Zonky
方法名:getTransactions

Zonky.getTransactions介绍

[英]Retrieve transactions from the wallet via TransactionApi.
[中]通过TransactionApi从钱包中检索交易。

代码示例

代码示例来源:origin: RoboZonky/robozonky

/**
 * Retrieve transactions from the wallet via {@link TransactionApi}.
 * @param investment Investment to filter the selection by.
 * @return All items from the remote API, lazy-loaded, filtered for the specific investment.
 */
public Stream<Transaction> getTransactions(final Investment investment) {
  final Select select = new Select().equals("investment.id", investment.getId());
  return getTransactions(select);
}

代码示例来源:origin: com.github.robozonky/robozonky-common

/**
 * Retrieve transactions from the wallet via {@link TransactionApi}.
 * @param investment Investment to filter the selection by.
 * @return All items from the remote API, lazy-loaded, filtered for the specific investment.
 */
public Stream<Transaction> getTransactions(final Investment investment) {
  final Select select = new Select().equals("investment.id", investment.getId());
  return getTransactions(select);
}

代码示例来源:origin: RoboZonky/robozonky

.map(OffsetDateTime::toLocalDate)
    .orElse(DateUtil.localNow().toLocalDate()).minusDays(i.getDaysPastDue());
final LocalDate lastPayment = getTransactions(i)
    .filter(t -> t.getCategory() == TransactionCategory.PAYMENT)
    .map(Transaction::getTransactionDate)

代码示例来源:origin: com.github.robozonky/robozonky-common

.map(OffsetDateTime::toLocalDate)
    .orElse(DateUtil.localNow().toLocalDate()).minusDays(i.getDaysPastDue());
final LocalDate lastPayment = getTransactions(i)
    .filter(t -> t.getCategory() == TransactionCategory.PAYMENT)
    .map(Transaction::getTransactionDate)

代码示例来源:origin: com.github.robozonky/robozonky-app

private static void run(final TransactionalPowerTenant tenant) {
  final InstanceState<IncomeProcessor> state = tenant.getState(IncomeProcessor.class);
  final long lastSeenTransactionId = state.getValue(STATE_KEY)
      .map(Integer::valueOf)
      .orElse(-1);
  // transactions from overnight processing have timestamps from the midnight of previous day
  final LocalDate lastUpdate = state.getLastUpdated()
      .map(u -> u.minusDays(1).toLocalDate())
      .orElse(DateUtil.localNow().toLocalDate().minusWeeks(1));
  final Select sinceLastUpdate = new Select().greaterThanOrEquals("transaction.transactionDate", lastUpdate);
  final Stream<Transaction> transactions = tenant.call(z -> z.getTransactions(sinceLastUpdate));
  final long newLastSeenTransactionId = lastSeenTransactionId >= 0 ?
      processNewTransactions(tenant, transactions, lastSeenTransactionId) :
      processAllTransactions(transactions);
  state.update(m -> m.put(STATE_KEY, String.valueOf(newLastSeenTransactionId)));
}

代码示例来源:origin: RoboZonky/robozonky

private static void run(final TransactionalPowerTenant tenant) {
  final InstanceState<IncomeProcessor> state = tenant.getState(IncomeProcessor.class);
  final long lastSeenTransactionId = state.getValue(STATE_KEY)
      .map(Integer::valueOf)
      .orElse(-1);
  // transactions from overnight processing have timestamps from the midnight of previous day
  final LocalDate lastUpdate = state.getLastUpdated()
      .map(u -> u.minusDays(1).toLocalDate())
      .orElse(DateUtil.localNow().toLocalDate().minusWeeks(1));
  final Select sinceLastUpdate = new Select().greaterThanOrEquals("transaction.transactionDate", lastUpdate);
  final Stream<Transaction> transactions = tenant.call(z -> z.getTransactions(sinceLastUpdate));
  final long newLastSeenTransactionId = lastSeenTransactionId >= 0 ?
      processNewTransactions(tenant, transactions, lastSeenTransactionId) :
      processAllTransactions(transactions);
  state.update(m -> m.put(STATE_KEY, String.valueOf(newLastSeenTransactionId)));
}

代码示例来源:origin: RoboZonky/robozonky

@Test
public void doesNotQueryAtFirstAttempt() {
  processor.accept(tenant);
  final Select s = new
      Select().greaterThanOrEquals("transaction.transactionDate", LocalDate.now().minusWeeks(1));
  verify(zonky, times(1)).getTransactions(eq(s));
  assertThat(state.getValue(IncomeProcessor.STATE_KEY)).hasValue("-1"); // nothing found
}

代码示例来源:origin: RoboZonky/robozonky

@Test
public void queriesAndKeepsPreviousMaxWhenNothingFound() {
  state.update(m -> m.put(IncomeProcessor.STATE_KEY, "1"));
  processor.accept(tenant);
  final Select s = new
      Select().greaterThanOrEquals("transaction.transactionDate", LocalDate.now().minusDays(1));
  verify(zonky, times(1)).getTransactions(eq(s));
  assertThat(state.getValue(IncomeProcessor.STATE_KEY)).hasValue("1"); // keep existing maximum
}

代码示例来源: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 getters() {
  final Zonky z = mockZonky();
  assertSoftly(softly -> {
    softly.assertThat(z.getAvailableLoans(Select.unrestricted())).isEmpty();
    softly.assertThat(z.getBlockedAmounts()).isEmpty();
    softly.assertThat(z.getInvestments(Select.unrestricted())).isEmpty();
    softly.assertThat(z.getInvestment(1)).isEmpty();
    softly.assertThat(z.getDelinquentInvestments()).isEmpty();
    softly.assertThat(z.getAvailableParticipations(Select.unrestricted())).isEmpty();
    softly.assertThat(z.getTransactions(Select.unrestricted())).isEmpty();
    softly.assertThat(z.getDevelopments(1)).isEmpty();
  });
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com