### Question:
AisConsentServiceRemote implements AisConsentServiceEncrypted { @Override public CmsResponse<CmsConsent> updateAspspAccountAccess(String consentId, AccountAccess request) { try { UpdateAisConsentResponse response = consentRestTemplate.exchange(remoteAisConsentUrls.updateAisAccountAccess(), HttpMethod.PUT, new HttpEntity<>(request), UpdateAisConsentResponse.class, consentId).getBody(); if (response != null) { return CmsResponse.<CmsConsent>builder() .payload(response.getAisConsent()) .build(); } } catch (CmsRestException cmsRestException) { log.info("Couldn't update ASPSP account access, HTTP response status: {}", cmsRestException.getHttpStatus()); return CmsResponse.<CmsConsent>builder() .error(cmsRestException.getCmsError()) .build(); } return CmsResponse.<CmsConsent>builder() .error(TECHNICAL_ERROR) .build(); }  @Override CmsResponse<CmsResponse.VoidResponse> checkConsentAndSaveActionLog(AisConsentActionRequest request); @Override CmsResponse<CmsConsent> updateAspspAccountAccess(String consentId, AccountAccess request);  }### Answer:
@Test void updateAspspAccountAccess() { when(aisConsentRemoteUrls.updateAisAccountAccess()).thenReturn(URL); AccountAccess accountAccess = buildEmptyAccountAccess(); CmsConsent updatedConsent = new CmsConsent(); when(consentRestTemplate.exchange(URL, HttpMethod.PUT, new HttpEntity<>(accountAccess), UpdateAisConsentResponse.class, CONSENT_ID)) .thenReturn(ResponseEntity.ok(new UpdateAisConsentResponse(updatedConsent))); CmsResponse<CmsConsent> response = aisConsentServiceRemote.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertTrue(response.isSuccessful()); assertEquals(updatedConsent, response.getPayload()); }
@Test void updateAspspAccountAccess_nullBody() { when(aisConsentRemoteUrls.updateAisAccountAccess()).thenReturn(URL); AccountAccess accountAccess = buildEmptyAccountAccess(); when(consentRestTemplate.exchange(URL, HttpMethod.PUT, new HttpEntity<>(accountAccess), UpdateAisConsentResponse.class, CONSENT_ID)) .thenReturn(ResponseEntity.ok().build()); CmsResponse<CmsConsent> response = aisConsentServiceRemote.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertTrue(response.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, response.getError()); }
@Test void updateAspspAccountAccess_cmsRestException() { when(aisConsentRemoteUrls.updateAisAccountAccess()).thenReturn(URL); AccountAccess accountAccess = buildEmptyAccountAccess(); when(consentRestTemplate.exchange(URL, HttpMethod.PUT, new HttpEntity<>(accountAccess), UpdateAisConsentResponse.class, CONSENT_ID)) .thenThrow(CmsRestException.class); CmsResponse<CmsConsent> response = aisConsentServiceRemote.updateAspspAccountAccess(CONSENT_ID, accountAccess); assertTrue(response.hasError()); assertEquals(CmsError.TECHNICAL_ERROR, response.getError()); }