### Question:
AspspPaymentServiceInternal implements AspspPaymentService { @Override @Transactional public boolean updatePaymentStatus(@NotNull String paymentId, @NotNull TransactionStatus status, @NotNull String instanceId) { Optional<PisCommonPaymentData> paymentDataOptional = commonPaymentDataService.getPisCommonPaymentData(paymentId, instanceId); return paymentDataOptional .map(pd -> commonPaymentDataService.updateStatusInPaymentData(pd, status)) .orElseGet(() -> { log.info("Payment ID [{}], Instance ID: [{}]. Update payment status failed, because PIS common payment data not found", paymentId, instanceId); return false; }); }  @Override @Transactional boolean updatePaymentStatus(@NotNull String paymentId, @NotNull TransactionStatus status, @NotNull String instanceId);  }### Answer:
@Test void updatePaymentStatus_Success() { when(commonPaymentDataService.getPisCommonPaymentData(PAYMENT_ID, DEFAULT_SERVICE_INSTANCE_ID)).thenReturn(Optional.of(pisCommonPaymentData)); when(commonPaymentDataService.updateStatusInPaymentData(pisCommonPaymentData, TRANSACTION_STATUS)).thenReturn(true); boolean actualResponse = aspspPaymentServiceInternal.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS, DEFAULT_SERVICE_INSTANCE_ID); assertTrue(actualResponse); }
@Test void updatePaymentStatus_Error() { when(commonPaymentDataService.getPisCommonPaymentData(PAYMENT_ID, DEFAULT_SERVICE_INSTANCE_ID)).thenReturn(Optional.empty()); boolean actualResponse = aspspPaymentServiceInternal.updatePaymentStatus(PAYMENT_ID, TRANSACTION_STATUS, DEFAULT_SERVICE_INSTANCE_ID); assertFalse(actualResponse); }