@Test public void shouldRemoveAgedPendingFunds() { final PendingFund pendingFund = PendingFundMother.aPendingFund(); when(pendingFundService.findAll()) .thenReturn(of(pendingFund)); when(azraelClient.getTransactionStatus(prettify(pendingFund.getTransactionHash()))).thenReturn(TransactionStatus.SUCCEEDED); ReflectionUtils.set(pendingFund, "creationDate", LocalDateTime.now().minusDays(2)); pendingFundCleaner.cleanupPendingFunds(); verify(pendingFundService).removePendingFund(pendingFund); }
@Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHash(), ex.getMessage()); return false; } }) .forEach(pendingFundService::removePendingFund); }
PendingFundCleaner { @Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHash(), ex.getMessage()); return false; } }) .forEach(pendingFundService::removePendingFund); } }
PendingFundCleaner { @Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHash(), ex.getMessage()); return false; } }) .forEach(pendingFundService::removePendingFund); } PendingFundCleaner(final PendingFundService pendingFundService,
                              final AzraelClient azraelClient); }
PendingFundCleaner { @Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHash(), ex.getMessage()); return false; } }) .forEach(pendingFundService::removePendingFund); } PendingFundCleaner(final PendingFundService pendingFundService,
                              final AzraelClient azraelClient); @Scheduled(fixedDelay = 300_000 /* 5 minutes */) void cleanupPendingFunds(); }
PendingFundCleaner { @Scheduled(fixedDelay = 300_000 ) public void cleanupPendingFunds() { pendingFundService.findAll() .stream() .filter(fund -> { try { return hasFailed(fund) || hasAged(fund); } catch (final Exception ex) { log.error("Unable to fetch status for transaction {} : ", fund.getTransactionHash(), ex.getMessage()); return false; } }) .forEach(pendingFundService::removePendingFund); } PendingFundCleaner(final PendingFundService pendingFundService,
                              final AzraelClient azraelClient); @Scheduled(fixedDelay = 300_000 /* 5 minutes */) void cleanupPendingFunds();  }