### Question:
PisCommonPaymentServiceInternal implements PisCommonPaymentService { @Override @Transactional public CmsResponse<TransactionStatus> getPisCommonPaymentStatusById(String paymentId) { Optional<TransactionStatus> statusOptional = pisCommonPaymentDataRepository.findByPaymentId(paymentId) .map(pisCommonPaymentConfirmationExpirationService::checkAndUpdateOnConfirmationExpiration) .map(PisCommonPaymentData::getTransactionStatus); if (statusOptional.isPresent()) { return CmsResponse.<TransactionStatus>builder() .payload(statusOptional.get()) .build(); } log.info("Payment ID: [{}]. Get common payment status by ID failed, because payment was not found by the ID", paymentId); return CmsResponse.<TransactionStatus>builder() .error(LOGICAL_ERROR) .build(); }  @Override @Transactional CmsResponse<CreatePisCommonPaymentResponse> createCommonPayment(PisPaymentInfo request); @Override @Transactional CmsResponse<TransactionStatus> getPisCommonPaymentStatusById(String paymentId); @Override @Transactional CmsResponse<PisCommonPaymentResponse> getCommonPaymentById(String paymentId); @Override @Transactional CmsResponse<Boolean> updateCommonPaymentStatusById(String paymentId, TransactionStatus status); @Override @Transactional CmsResponse<Boolean> updateMultilevelSca(String paymentId, boolean multilevelScaRequired); @Override CmsResponse<List<PsuIdData>> getPsuDataListByPaymentId(String paymentId);  }### Answer:
@Test void getPisCommonPaymentStatusById_success() { when(pisCommonPaymentDataRepository.findByPaymentId(PAYMENT_ID)).thenReturn(Optional.of(pisCommonPaymentData)); when(pisCommonPaymentConfirmationExpirationService.checkAndUpdateOnConfirmationExpiration(pisCommonPaymentData)) .thenReturn(pisCommonPaymentData); CmsResponse<TransactionStatus> actual = pisCommonPaymentService.getPisCommonPaymentStatusById(PAYMENT_ID); assertTrue(actual.isSuccessful()); assertEquals(TransactionStatus.RCVD, actual.getPayload()); }
@Test void getPisCommonPaymentStatusById_logicalError() { when(pisCommonPaymentDataRepository.findByPaymentId(PAYMENT_ID)).thenReturn(Optional.of(pisCommonPaymentData)); when(pisCommonPaymentConfirmationExpirationService.checkAndUpdateOnConfirmationExpiration(pisCommonPaymentData)) .thenReturn(null); CmsResponse<TransactionStatus> actual = pisCommonPaymentService.getPisCommonPaymentStatusById(PAYMENT_ID); assertTrue(actual.hasError()); assertEquals(CmsError.LOGICAL_ERROR, actual.getError()); }