class ConsentScheduleTask {

    @Scheduled(cron = "${xs2a.cms.consent.cron.expression}")
    @Transactional
    public void checkConsentStatus() {
        log.info("Consent schedule task is run!");
        List<ConsentEntity> availableConsents = Optional.ofNullable(consentJpaRepository.findByConsentStatusIn(EnumSet.of(RECEIVED, VALID)))
                                                 .orElse(Collections.emptyList());
        consentJpaRepository.saveAll(updateConsent(availableConsents));
    }

}