### Question:
AisConsentRepositoryImpl implements AisConsentVerifyingRepository { @Override @Transactional(rollbackFor = WrongChecksumException.class) public ConsentEntity verifyAndSave(ConsentEntity entity) throws WrongChecksumException { return verifyAndSaveInternal(entity); }  @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 verifyAndSave_ReceivedToValidStatus_success() throws WrongChecksumException { when(calculatingFactory.getServiceByChecksum(any(), eq(ConsentType.AIS))) .thenReturn(Optional.of(checksumCalculatingService)); ConsentEntity previousConsentEntity = buildConsentEntity(ConsentStatus.RECEIVED); when(aisConsentRepository.findByExternalId(consentEntity.getExternalId())) .thenReturn(Optional.of(previousConsentEntity)); when(aisConsentRepository.save(consentEntity)) .thenReturn(consentEntity); ConsentEntity actualResult = aisConsentVerifyingRepository.verifyAndSave(consentEntity); assertEquals(consentEntity, actualResult); verify(aisConsentRepository, times(1)).save(consentEntity); }