### Question:
DecoupledAisAuthorizationService implements AisAuthorizationService { @Override public Optional<CreateConsentAuthorizationResponse> createConsentAuthorization(PsuIdData psuData, String consentId) { Optional<AisConsent> aisConsentOptional = aisConsentService.getAccountConsentById(consentId); if (aisConsentOptional.isEmpty()) { log.info("Consent-ID [{}]. Create consent authorisation has failed. Consent not found by id.", consentId); return Optional.empty(); } return consentService.createConsentAuthorisation(consentId, ScaStatus.RECEIVED, psuData) .map(auth -> { CreateConsentAuthorizationResponse resp = new CreateConsentAuthorizationResponse(); resp.setConsentId(consentId); resp.setAuthorisationId(auth.getAuthorizationId()); resp.setScaStatus(auth.getScaStatus()); resp.setPsuIdData(psuData); return resp; }); }  @Override Optional<CreateConsentAuthorizationResponse> createConsentAuthorization(PsuIdData psuData, String consentId); @Override AuthorisationProcessorResponse updateConsentPsuData(UpdateAuthorisationRequest request, AuthorisationProcessorResponse response); @Override Optional<Authorisation> getConsentAuthorizationById(String authorisationId); @Override Optional<ScaStatus> getAuthorisationScaStatus(String consentId, String authorisationId); @Override ScaApproach getScaApproachServiceType();  }### Answer:
@Test void createConsentAuthorization_success() { when(aisConsentService.getAccountConsentById(CONSENT_ID)) .thenReturn(Optional.of(buildConsent(CONSENT_ID))); when(consentService.createConsentAuthorisation(CONSENT_ID, SCA_STATUS, PSU_DATA)) .thenReturn(Optional.of(buildCreateAuthorisationResponse())); Optional<CreateConsentAuthorizationResponse> actualResponse = decoupledAisAuthorizationService.createConsentAuthorization(PSU_DATA, CONSENT_ID); assertThat(actualResponse.isPresent()).isTrue(); assertThat(actualResponse.get()).isEqualTo(CREATE_CONSENT_AUTHORIZATION_RESPONSE); }
@Test void createConsentAuthorization_wrongConsentId_fail() { when(aisConsentService.getAccountConsentById(WRONG_CONSENT_ID)) .thenReturn(Optional.empty()); Optional<CreateConsentAuthorizationResponse> actualResponse = decoupledAisAuthorizationService.createConsentAuthorization(PSU_DATA, WRONG_CONSENT_ID); assertThat(actualResponse.isPresent()).isFalse(); }