### Question:
EmbeddedPisScaAuthorisationService implements PisScaAuthorisationService { @Override public Optional<Xs2aCreatePisAuthorisationResponse> createCommonPaymentAuthorisation(String paymentId, PaymentType paymentType, PsuIdData psuData) { return pisCommonPaymentMapper.mapToXsa2CreatePisAuthorisationResponse(authorisationService.createPisAuthorisation(paymentId, psuData), paymentType); }  @Override Optional<Xs2aCreatePisAuthorisationResponse> createCommonPaymentAuthorisation(String paymentId, PaymentType paymentType, PsuIdData psuData); @Override Xs2aUpdatePisCommonPaymentPsuDataResponse updateCommonPaymentPsuData(Xs2aUpdatePisCommonPaymentPsuDataRequest request); @Override void updateAuthorisation(UpdateAuthorisationRequest request, AuthorisationProcessorResponse response); @Override void updateCancellationAuthorisation(UpdateAuthorisationRequest request, AuthorisationProcessorResponse response); @Override Optional<Xs2aCreatePisCancellationAuthorisationResponse> createCommonPaymentCancellationAuthorisation(String paymentId, PaymentType paymentType, PsuIdData psuData); @Override Optional<Xs2aPaymentCancellationAuthorisationSubResource> getCancellationAuthorisationSubResources(String paymentId); @Override Xs2aUpdatePisCommonPaymentPsuDataResponse updateCommonPaymentCancellationPsuData(Xs2aUpdatePisCommonPaymentPsuDataRequest request); @Override Optional<Xs2aAuthorisationSubResources> getAuthorisationSubResources(String paymentId); @Override Optional<ScaStatus> getAuthorisationScaStatus(String paymentId, String authorisationId); @Override Optional<ScaStatus> getCancellationAuthorisationScaStatus(String paymentId, String authorisationId); @Override ScaApproach getScaApproachServiceType();  }### Answer:
@Test void createCommonPaymentAuthorisation_success() { when(pisAuthorisationService.createPisAuthorisation(PAYMENT_ID, PSU_ID_DATA)) .thenReturn(CREATE_PIS_AUTHORISATION_RESPONSE); when(pisCommonPaymentMapper.mapToXsa2CreatePisAuthorisationResponse(CREATE_PIS_AUTHORISATION_RESPONSE, PAYMENT_TYPE)) .thenReturn(Optional.of(XS2A_CREATE_PIS_AUTHORISATION_RESPONSE)); Optional<Xs2aCreatePisAuthorisationResponse> actualResponse = embeddedPisScaAuthorisationService.createCommonPaymentAuthorisation(PAYMENT_ID, PAYMENT_TYPE, PSU_ID_DATA); assertThat(actualResponse.isPresent()).isTrue(); assertThat(actualResponse).isEqualTo(Optional.of(XS2A_CREATE_PIS_AUTHORISATION_RESPONSE)); }
@Test void createCommonPaymentAuthorisation_wrongId_fail() { when(pisAuthorisationService.createPisAuthorisation(WRONG_PAYMENT_ID, PSU_ID_DATA)) .thenReturn(WRONG_CREATE_PIS_AUTHORISATION_RESPONSE); when(pisCommonPaymentMapper.mapToXsa2CreatePisAuthorisationResponse(WRONG_CREATE_PIS_AUTHORISATION_RESPONSE, PAYMENT_TYPE)) .thenReturn(Optional.empty()); Optional<Xs2aCreatePisAuthorisationResponse> actualResponse = embeddedPisScaAuthorisationService.createCommonPaymentAuthorisation(WRONG_PAYMENT_ID, PAYMENT_TYPE, PSU_ID_DATA); assertThat(actualResponse.isPresent()).isFalse(); }