### Question:
CommonDecoupledAisService extends CommonDecoupledConsentService<SpiAccountConsent> { @Override protected SpiResponse<SpiAuthorisationDecoupledScaResponse> startScaDecoupled(SpiContextData spiContextData, String authorisationId, String authenticationMethodId, SpiAccountConsent spiConsent, SpiAspspConsentDataProvider spiAspspConsentDataProvider) { return aisConsentSpi.startScaDecoupled(spiContextData, authorisationId, authenticationMethodId, spiConsent, spiAspspConsentDataProvider); } CommonDecoupledAisService(SpiErrorMapper spiErrorMapper,
                                     SpiAspspConsentDataProviderFactory aspspConsentDataProviderFactory,
                                     SpiContextDataProvider spiContextDataProvider,
                                     Xs2aAuthorisationService authorisationService,
                                     AisConsentSpi aisConsentSpi);   }### Answer:
@Test void proceedDecoupledApproach_by_request_spiAccountConsent_psuData_success() { when(aisConsentSpi.startScaDecoupled(SPI_CONTEXT_DATA, AUTHORISATION_ID, null, spiAccountConsent, spiAspspConsentDataProvider)) .thenReturn(buildSuccessSpiResponse(new SpiAuthorisationDecoupledScaResponse(PSU_SUCCESS_MESSAGE))); UpdateConsentPsuDataResponse actualResponse = commonDecoupledAisService.proceedDecoupledApproach(CONSENT_ID, AUTHORISATION_ID, spiAccountConsent, PSU_ID_DATA); assertThat(actualResponse).isEqualTo(UPDATE_CONSENT_PSU_DATA_RESPONSE); }
@Test void proceedDecoupledApproach_Success() { when(aisConsentSpi.startScaDecoupled(SPI_CONTEXT_DATA, AUTHORISATION_ID, AUTHENTICATION_METHOD_ID, spiAccountConsent, spiAspspConsentDataProvider)) .thenReturn(buildSuccessSpiResponse(new SpiAuthorisationDecoupledScaResponse(PSU_SUCCESS_MESSAGE))); UpdateConsentPsuDataResponse actualResponse = commonDecoupledAisService.proceedDecoupledApproach(CONSENT_ID, AUTHORISATION_ID, spiAccountConsent, AUTHENTICATION_METHOD_ID, PSU_ID_DATA); assertThat(actualResponse).isNotNull(); assertThat(actualResponse.getPsuMessage()).isEqualTo(PSU_SUCCESS_MESSAGE); assertThat(actualResponse.getScaStatus()).isEqualTo(METHOD_SELECTED_SCA_STATUS); }
@Test void proceedDecoupledApproach_Failure_StartScaDecoupledHasError() { when(aisConsentSpi.startScaDecoupled(SPI_CONTEXT_DATA, AUTHORISATION_ID, AUTHENTICATION_METHOD_ID, spiAccountConsent, spiAspspConsentDataProvider)) .thenReturn(buildErrorSpiResponse(new SpiAuthorisationDecoupledScaResponse(PSU_ERROR_MESSAGE))); when(spiErrorMapper.mapToErrorHolder(buildErrorSpiResponse(new SpiAuthorisationDecoupledScaResponse(PSU_ERROR_MESSAGE)), ServiceType.AIS)) .thenReturn(ErrorHolder .builder(ErrorType.AIS_400) .tppMessages(TppMessageInformation.of(MessageErrorCode.FORMAT_ERROR)) .build()); UpdateConsentPsuDataResponse actualResponse = commonDecoupledAisService.proceedDecoupledApproach(CONSENT_ID, AUTHORISATION_ID, spiAccountConsent, AUTHENTICATION_METHOD_ID, PSU_ID_DATA); assertThat(actualResponse).isNotNull(); assertThat(actualResponse.getScaStatus()).isEqualTo(FAILED_SCA_STATUS); assertThat(actualResponse.getErrorHolder().getErrorType()).isEqualTo(ErrorType.AIS_400); }