### Question:
Xs2aUpdatePaymentAfterSpiService { public boolean updatePaymentStatus(@NotNull String paymentId, @NotNull TransactionStatus status) { CmsResponse<Boolean> response = updatePaymentStatusAfterSpiService.updatePaymentStatus(paymentId, status); boolean statusUpdated = response.isSuccessful() && response.getPayload(); if (statusUpdated) { loggingContextService.storeTransactionStatus(status); } return statusUpdated; }  boolean updatePaymentStatus(@NotNull String paymentId, @NotNull TransactionStatus status); boolean updatePaymentCancellationTppRedirectUri(@NotNull String paymentId, @NotNull TppRedirectUri tppRedirectUri); boolean updatePaymentCancellationInternalRequestId(@NotNull String paymentId, @NotNull String internalRequestId);  }### Answer:
@Test void updatePaymentStatus_success() { when(updatePaymentStatusAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS)) .thenReturn(CmsResponse.<Boolean>builder().payload(true).build()); boolean actualResponse = xs2AUpdatePaymentAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS); assertThat(actualResponse).isTrue(); }
@Test void updatePaymentStatus_failed() { when(updatePaymentStatusAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS)) .thenReturn(CmsResponse.<Boolean>builder().payload(false).build()); boolean actualResponse = xs2AUpdatePaymentAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS); assertThat(actualResponse).isFalse(); }
@Test void updatePaymentStatus_success_shouldStoreTransactionStatusInLoggingContext() { when(updatePaymentStatusAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS)) .thenReturn(CmsResponse.<Boolean>builder().payload(true).build()); boolean actualResponse = xs2AUpdatePaymentAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS); assertThat(actualResponse).isTrue(); verify(loggingContextService).storeTransactionStatus(TRANSACTION_STATUS); }
@Test void updatePaymentStatus_failure_shouldNotStoreTransactionStatusInLoggingContext() { when(updatePaymentStatusAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS)) .thenReturn(CmsResponse.<Boolean>builder().payload(false).build()); boolean actualResponse = xs2AUpdatePaymentAfterSpiService.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS); assertThat(actualResponse).isFalse(); verify(loggingContextService, never()).storeTransactionStatus(any()); }