### Question:
AisConsentRepositoryImpl implements AisConsentVerifyingRepository { @Override @Transactional public Optional<ConsentEntity> getActualAisConsent(String consentId) { return aisConsentRepository.findByExternalId(consentId) .filter(c -> !c.getConsentStatus().isFinalisedStatus()); }  @Override @Transactional(rollbackFor = WrongChecksumException.class) ConsentEntity verifyAndSave(ConsentEntity entity); @Override @Transactional(rollbackFor = WrongChecksumException.class) ConsentEntity verifyAndUpdate(ConsentEntity entity); @Override @Transactional(rollbackFor = WrongChecksumException.class) List<ConsentEntity> verifyAndSaveAll(List<ConsentEntity> consents); @Override @Transactional Optional<ConsentEntity> getActualAisConsent(String consentId);  }### Answer:
@Test void getActualAisConsent_success() { when(aisConsentRepository.findByExternalId(consentEntity.getExternalId())) .thenReturn(Optional.of(consentEntity)); Optional<ConsentEntity> optionalConsentEntity = aisConsentVerifyingRepository.getActualAisConsent(consentEntity.getExternalId()); assertEquals(Optional.of(consentEntity), optionalConsentEntity); }
@Test void getActualAisConsent_empty() { consentEntity.setConsentStatus(ConsentStatus.REJECTED); when(aisConsentRepository.findByExternalId(consentEntity.getExternalId())) .thenReturn(Optional.of(consentEntity)); Optional<ConsentEntity> optionalConsentEntity = aisConsentVerifyingRepository.getActualAisConsent(consentEntity.getExternalId()); assertEquals(Optional.empty(), optionalConsentEntity); }