### Question:
NonRecurringConsentExpirationScheduleTask { @Scheduled(cron = "${xs2a.cms.used-non-recurring-consent-expiration.cron.expression}") @Transactional public void expireUsedNonRecurringConsent() { log.info("Non-recurring consent expiration task has started!"); List<ConsentEntity> consents = consentJpaRepository.findUsedNonRecurringConsents(EnumSet.of(RECEIVED, VALID), LocalDate.now()) .stream() .distinct() .map(this::expireConsent) .collect(Collectors.toList()); consentJpaRepository.saveAll(consents); }  @Scheduled(cron = "${xs2a.cms.used-non-recurring-consent-expiration.cron.expression}") @Transactional void expireUsedNonRecurringConsent();  }### Answer:
@Test void expireUsedNonRecurringConsent() { List<ConsentEntity> aisConsents = new ArrayList<>(); aisConsents.add(createConsent(RECEIVED)); aisConsents.add(createConsent(VALID)); when(consentJpaRepository.findUsedNonRecurringConsents(eq(EnumSet.of(RECEIVED, VALID)), any(LocalDate.class))) .thenReturn(aisConsents); when(consentJpaRepository.saveAll(consentsCaptor.capture())).thenReturn(Collections.emptyList()); scheduleTask.expireUsedNonRecurringConsent(); verify(consentJpaRepository, times(1)).findUsedNonRecurringConsents(eq(EnumSet.of(RECEIVED, VALID)), any(LocalDate.class)); verify(consentJpaRepository, times(1)).saveAll(anyList()); assertEquals(2, consentsCaptor.getValue().size()); consentsCaptor.getValue().forEach(c -> assertEquals(EXPIRED, c.getConsentStatus())); }