class NotConfirmedPaymentExpirationScheduleTask {

    @Scheduled(cron = "${xs2a.cms.not-confirmed-payment-expiration.cron.expression}")
    @Transactional
    public void obsoleteNotConfirmedPaymentIfExpired() {
        log.info("Not confirmed payment expiration schedule task is run!");

        List<PisCommonPaymentData> expiredNotConfirmedPaymentDatas = paymentDataRepository.findByTransactionStatusIn(EnumSet.of(TransactionStatus.RCVD, TransactionStatus.PATC))
                                                                         .stream()
                                                                         .filter(pisCommonPaymentConfirmationExpirationService::isConfirmationExpired)
                                                                         .collect(Collectors.toList());

        if (CollectionUtils.isNotEmpty(expiredNotConfirmedPaymentDatas)) {
            pisCommonPaymentConfirmationExpirationService.updatePaymentDataListOnConfirmationExpiration(expiredNotConfirmedPaymentDatas);
        }
    }

}