### Question:
AisConsentServiceInternalEncrypted implements AisConsentServiceEncrypted { @Override @Transactional(rollbackFor = WrongChecksumException.class) public CmsResponse<CmsConsent> updateAspspAccountAccess(String encryptedConsentId, AccountAccess request) throws WrongChecksumException { Optional<String> decryptIdOptional = securityDataService.decryptId(encryptedConsentId); if (decryptIdOptional.isEmpty()) { log.info("Encrypted Consent ID: [{}]. Update aspsp account access with response failed, couldn't decrypt consent id", encryptedConsentId); return CmsResponse.<CmsConsent>builder() .error(TECHNICAL_ERROR) .build(); } return aisConsentService.updateAspspAccountAccess(decryptIdOptional.get(), request); }  @Override @Transactional(rollbackFor = WrongChecksumException.class) CmsResponse<CmsResponse.VoidResponse> checkConsentAndSaveActionLog(AisConsentActionRequest encryptedRequest); @Override @Transactional(rollbackFor = WrongChecksumException.class) CmsResponse<CmsConsent> updateAspspAccountAccess(String encryptedConsentId, AccountAccess request);  }### Answer:
@Test void updateAccountAccess_success() throws WrongChecksumException { CmsConsent cmsConsent = buildCmsConsent(); AccountAccess accountAccess = buildAccountAccess(); when(securityDataService.decryptId(ENCRYPTED_CONSENT_ID)).thenReturn(Optional.of(DECRYPTED_CONSENT_ID)); when(aisConsentService.updateAspspAccountAccess(eq(DECRYPTED_CONSENT_ID), any())) .thenReturn(CmsResponse.<CmsConsent>builder() .payload(cmsConsent) .build()); CmsResponse<CmsConsent> actual = aisConsentServiceInternalEncrypted.updateAspspAccountAccess(ENCRYPTED_CONSENT_ID, accountAccess); assertTrue(actual.isSuccessful()); assertEquals(DECRYPTED_CONSENT_ID, actual.getPayload().getId()); verify(aisConsentService, times(1)).updateAspspAccountAccess(DECRYPTED_CONSENT_ID, accountAccess); }
@Test void updateAccountAccess_internalServiceFailed() throws WrongChecksumException { when(securityDataService.decryptId(ENCRYPTED_CONSENT_ID)).thenReturn(Optional.of(DECRYPTED_CONSENT_ID)); when(aisConsentService.updateAspspAccountAccess(any(), any())) .thenReturn(CmsResponse.<CmsConsent>builder() .error(CmsError.LOGICAL_ERROR) .build()); AccountAccess accountAccess = buildAccountAccess(); CmsResponse<CmsConsent> actual = aisConsentServiceInternalEncrypted.updateAspspAccountAccess(ENCRYPTED_CONSENT_ID, accountAccess); assertTrue(actual.hasError()); assertEquals(CmsError.LOGICAL_ERROR, actual.getError()); verify(aisConsentService, times(1)).updateAspspAccountAccess(DECRYPTED_CONSENT_ID, accountAccess); }
@Test void updateAccountAccess_decryptionFailed() throws WrongChecksumException { AccountAccess accountAccess = buildAccountAccess(); CmsResponse<CmsConsent> actual = aisConsentServiceInternalEncrypted.updateAspspAccountAccess(UNDECRYPTABLE_CONSENT_ID, accountAccess); assertTrue(actual.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actual.getError()); verify(aisConsentService, never()).updateAspspAccountAccess(any(), any()); }