### Question:
Xs2aAisConsentService { public CmsResponse<AisConsent> updateAspspAccountAccess(String consentId, AccountAccess accountAccess) { CmsResponse<CmsConsent> response; CmsResponse.CmsResponseBuilder<AisConsent> builder = CmsResponse.builder(); try { response = aisConsentService.updateAspspAccountAccess(consentId, accountAccess); } catch (WrongChecksumException e) { return builder.error(CmsError.CHECKSUM_ERROR).build(); } if (response.hasError()) { return builder.error(response.getError()).build(); } return builder.payload(aisConsentMapper.mapToAisConsent(response.getPayload())).build(); }  Optional<Xs2aCreateAisConsentResponse> createConsent(CreateConsentReq request, PsuIdData psuData, TppInfo tppInfo); Optional<AisConsent> getAccountConsentById(String consentId); boolean findAndTerminateOldConsentsByNewConsentId(String newConsentId); void updateConsentStatus(String consentId, ConsentStatus consentStatus); void consentActionLog(String tppId, String consentId, ActionStatus actionStatus, String requestUri, boolean updateUsage,
                                 String resourceId, String transactionId); void updateConsentAuthorisation(UpdateConsentPsuDataReq updatePsuData); CmsResponse<AisConsent> updateAspspAccountAccess(String consentId, AccountAccess accountAccess); Optional<List<String>> getAuthorisationSubResources(String consentId); void updateMultilevelScaRequired(String consentId, boolean multilevelScaRequired);  }### Answer:
@Test void updateAspspAccountAccess() throws WrongChecksumException { AccountAccess accountAccess = jsonReader.getObjectFromFile("json/aspect/account-access.json", AccountAccess.class); CmsConsent cmsConsent = new CmsConsent(); when(aisConsentServiceEncrypted.updateAspspAccountAccess(CONSENT_ID, accountAccess)) .thenReturn(CmsResponse.<CmsConsent>builder().payload(cmsConsent).build()); when(aisConsentMapper.mapToAisConsent(cmsConsent)).thenReturn(aisConsent); CmsResponse<AisConsent> actual = xs2aAisConsentService.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertFalse(actual.hasError()); assertEquals(aisConsent, actual.getPayload()); }
@Test void updateAspspAccountAccess_checksumError() throws WrongChecksumException { AccountAccess accountAccess = jsonReader.getObjectFromFile("json/aspect/account-access.json", AccountAccess.class); when(aisConsentServiceEncrypted.updateAspspAccountAccess(CONSENT_ID, accountAccess)) .thenThrow(new WrongChecksumException()); CmsResponse<AisConsent> actual = xs2aAisConsentService.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertTrue(actual.hasError()); assertEquals(CmsError.CHECKSUM_ERROR, actual.getError()); }
@Test void updateAspspAccountAccess_updateError() throws WrongChecksumException { AccountAccess accountAccess = jsonReader.getObjectFromFile("json/aspect/account-access.json", AccountAccess.class); when(aisConsentServiceEncrypted.updateAspspAccountAccess(CONSENT_ID, accountAccess)) .thenReturn(CmsResponse.<CmsConsent>builder().error(CmsError.TECHNICAL_ERROR).build()); CmsResponse<AisConsent> actual = xs2aAisConsentService.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertTrue(actual.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, actual.getError()); }