### Question:
Xs2aAisConsentService { public Optional<AisConsent> getAccountConsentById(String consentId) { CmsResponse<CmsConsent> consentById = consentService.getConsentById(consentId); if (consentById.hasError()) { log.info("Get consent by id failed due to CMS problems"); return Optional.empty(); } return Optional.ofNullable(aisConsentMapper.mapToAisConsent(consentById.getPayload())); }  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 getAccountConsentById_success() { when(consentServiceEncrypted.getConsentById(CONSENT_ID)) .thenReturn(CmsResponse.<CmsConsent>builder().payload(CMS_CONSENT).build()); when(aisConsentMapper.mapToAisConsent(CMS_CONSENT)) .thenReturn(aisConsent); Optional<AisConsent> actualResponse = xs2aAisConsentService.getAccountConsentById(CONSENT_ID); assertThat(actualResponse.isPresent()).isTrue(); assertThat(actualResponse.get()).isEqualTo(aisConsent); }
@Test void getAccountConsentById_failed() { when(consentServiceEncrypted.getConsentById(CONSENT_ID)) .thenReturn(CmsResponse.<CmsConsent>builder().error(CmsError.TECHNICAL_ERROR).build()); Optional<AisConsent> actualResponse = xs2aAisConsentService.getAccountConsentById(CONSENT_ID); assertThat(actualResponse.isPresent()).isFalse(); }