class NotConfirmedConsentExpirationScheduleTask {

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

        List<ConsentEntity> expiredNotConfirmedConsents = consentJpaRepository.findByConsentStatusIn(EnumSet.of(ConsentStatus.RECEIVED, ConsentStatus.PARTIALLY_AUTHORISED))
                                                              .stream()
                                                              .filter(aisConsentConfirmationExpirationService::isConfirmationExpired)
                                                              .collect(Collectors.toList());

        if (CollectionUtils.isNotEmpty(expiredNotConfirmedConsents)) {
            aisConsentConfirmationExpirationService.updateConsentListOnConfirmationExpiration(expiredNotConfirmedConsents);
        }
    }

}