### Question:
ReadCommonPaymentStatusService implements ReadPaymentStatusService { @Override public ReadPaymentStatusResponse readPaymentStatus(CommonPaymentData commonPaymentData, SpiContextData spiContextData, @NotNull String encryptedPaymentId, String acceptMediaType) { CommonPayment commonPayment = cmsToXs2aPaymentMapper.mapToXs2aCommonPayment(commonPaymentData); SpiPaymentInfo request = xs2aToSpiPaymentInfoMapper.mapToSpiPaymentInfo(commonPayment); SpiAspspConsentDataProvider aspspConsentDataProvider = aspspConsentDataProviderFactory.getSpiAspspDataProviderFor(encryptedPaymentId); SpiResponse<SpiGetPaymentStatusResponse> spiResponse = commonPaymentSpi.getPaymentStatusById(spiContextData, acceptMediaType, request, aspspConsentDataProvider); if (spiResponse.hasError()) { ErrorHolder errorHolder = spiErrorMapper.mapToErrorHolder(spiResponse, ServiceType.PIS); log.info("Payment-ID [{}]. READ COMMON Payment STATUS failed. Can't get Payment status by ID at SPI level. Error msg: [{}]", commonPayment.getPaymentId(), errorHolder); return new ReadPaymentStatusResponse(errorHolder); } SpiGetPaymentStatusResponse payload = spiResponse.getPayload(); return new ReadPaymentStatusResponse(payload.getTransactionStatus(), payload.getFundsAvailable(), mediaTypeMapper.mapToMediaType(payload.getResponseContentType()), payload.getPaymentStatusRaw(), payload.getPsuMessage()); }  @Override ReadPaymentStatusResponse readPaymentStatus(CommonPaymentData commonPaymentData, SpiContextData spiContextData, @NotNull String encryptedPaymentId, String acceptMediaType);  }### Answer:
@Test void readPaymentStatus_success() { when(commonPaymentSpi.getPaymentStatusById(SPI_CONTEXT_DATA, JSON_MEDIA_TYPE, SPI_PAYMENT_INFO, spiAspspConsentDataProvider)) .thenReturn(TRANSACTION_RESPONSE); when(mediaTypeMapper.mapToMediaType(JSON_MEDIA_TYPE)) .thenReturn(MediaType.APPLICATION_JSON); ReadPaymentStatusResponse actualResponse = readCommonPaymentStatusService.readPaymentStatus(PIS_COMMON_PAYMENT_RESPONSE, SPI_CONTEXT_DATA, SOME_ENCRYPTED_PAYMENT_ID, JSON_MEDIA_TYPE); assertThat(actualResponse).isEqualTo(READ_PAYMENT_STATUS_RESPONSE); }
@Test void readPaymentStatus_failed() { ErrorHolder expectedError = ErrorHolder.builder(ErrorType.PIS_404) .tppMessages(TppMessageInformation.of(MessageErrorCode.RESOURCE_UNKNOWN_404_NO_PAYMENT)) .build(); when(commonPaymentSpi.getPaymentStatusById(SPI_CONTEXT_DATA, JSON_MEDIA_TYPE, SPI_PAYMENT_INFO, spiAspspConsentDataProvider)) .thenReturn(TRANSACTION_RESPONSE_FAILURE); when(spiErrorMapper.mapToErrorHolder(TRANSACTION_RESPONSE_FAILURE, ServiceType.PIS)) .thenReturn(expectedError); ReadPaymentStatusResponse actualResponse = readCommonPaymentStatusService.readPaymentStatus(PIS_COMMON_PAYMENT_RESPONSE, SPI_CONTEXT_DATA, SOME_ENCRYPTED_PAYMENT_ID, JSON_MEDIA_TYPE); assertThat(actualResponse.hasError()).isTrue(); assertThat(actualResponse.getErrorHolder()).isEqualToComparingFieldByField(expectedError); }