### Question:
RequestVacuumer { @Scheduled(fixedDelay = 300_000L) public void cleanClaims() { final List<RequestClaim> claims = requestClaimRepository.findByStatus(ClaimRequestStatus.APPROVED); claims.stream() .filter(x -> x.getTransactionHash() != null) .filter(x -> azraelClient.getTransactionStatus(x.getTransactionHash()).equals(TransactionStatus.FAILED)) .forEach(x -> { x.setStatus(ClaimRequestStatus.TRANSACTION_FAILED); requestClaimRepository.save(x); }); } RequestVacuumer(final RequestClaimRepository requestClaimRepository,
                           final RefundRequestRepository refundRequestRepository,
                           final AzraelClient azraelClient); @Scheduled(fixedDelay = 300_000L) void cleanClaims(); @Scheduled(fixedDelay = 300_000L) void cleanRefunds();  }### Answer:
@Test void cleanClaims() { final RequestClaim requestClaim1 = RequestClaim.builder().status(ClaimRequestStatus.APPROVED).transactionHash("0x213").build(); final RequestClaim requestClaim2 = RequestClaim.builder().status(ClaimRequestStatus.APPROVED).transactionHash("0x3243").build(); final RequestClaim requestClaim3 = RequestClaim.builder().status(ClaimRequestStatus.APPROVED).transactionHash(null).build(); final RequestClaim requestClaim4 = RequestClaim.builder().status(ClaimRequestStatus.APPROVED).transactionHash("0x687").build(); when(requestClaimRepository.findByStatus(ClaimRequestStatus.APPROVED)).thenReturn(Arrays.asList(requestClaim1, requestClaim2, requestClaim3, requestClaim4)); when(azraelClient.getTransactionStatus(requestClaim1.getTransactionHash())).thenReturn(TransactionStatus.SUCCEEDED); when(azraelClient.getTransactionStatus(requestClaim2.getTransactionHash())).thenReturn(TransactionStatus.NOT_FOUND); when(azraelClient.getTransactionStatus(requestClaim4.getTransactionHash())).thenReturn(TransactionStatus.FAILED); requestVacuumer.cleanClaims(); assertThat(requestClaim1.getStatus()).isEqualTo(ClaimRequestStatus.APPROVED); assertThat(requestClaim2.getStatus()).isEqualTo(ClaimRequestStatus.APPROVED); assertThat(requestClaim3.getStatus()).isEqualTo(ClaimRequestStatus.APPROVED); assertThat(requestClaim4.getStatus()).isEqualTo(ClaimRequestStatus.TRANSACTION_FAILED); verify(requestClaimRepository).findByStatus(ClaimRequestStatus.APPROVED); verify(requestClaimRepository).save(requestClaim4); verifyNoMoreInteractions(requestClaimRepository); }