diff --git a/build.gradle b/build.gradle index 737d152d..b479fb3d 100644 --- a/build.gradle +++ b/build.gradle @@ -112,7 +112,7 @@ dependencies { // Mocking libraries testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.12.0' - testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.0' + testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.1' // Wait test utility testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.2.1' diff --git a/gradle.properties b/gradle.properties index 4f0da905..12b06251 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Main properties group=com.truelayer archivesBaseName=truelayer-java -version=13.1.0 +version=13.1.1 # Artifacts properties sonatype_repository_url=https://s01.oss.sonatype.org/service/local/ diff --git a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java index 3b90583e..11fd5015 100644 --- a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java @@ -413,6 +413,9 @@ public void shouldReturnAttemptFailedPaymentStatusIfAuthorizationIsRejectedWithR .resource(HeadlessResource.PAYMENTS) .build()); + // sometimes status change event has a bit of delay + waitForPaymentStatusUpdate(createPaymentResponse.getData().getId(), Status.ATTEMPT_FAILED); + // get by id ApiResponse getPaymentByIdResponse = tlClient.payments() .getPayment(createPaymentResponse.getData().getId()) @@ -467,7 +470,7 @@ public void shouldCreateAPaymentRefundAndGetRefundDetails() { .resource(HeadlessResource.PAYMENTS) .build()); - waitForPaymentToBeSettled(paymentId); + waitForPaymentStatusUpdate(paymentId, Status.SETTLED); // Create full payment refund CreatePaymentRefundRequest createPaymentRefundRequest = CreatePaymentRefundRequest.builder() @@ -636,7 +639,7 @@ private void assertCanBrowseLink(URI link) { assertTrue(hppResponse.isSuccessful()); } - private void waitForPaymentToBeSettled(String paymentId) { + private void waitForPaymentStatusUpdate(String paymentId, Status paymentStatus) { await().with() .conditionEvaluationListener(new ConditionEvaluationListener() { @Override @@ -644,8 +647,7 @@ public void conditionEvaluated(EvaluatedCondition condition) {} @Override public void onTimeout(TimeoutEvent timeoutEvent) { - Logger.warn( - "Payment is taking too much time to settle, status polling timed out. Refunds test cannot be evaluated without a settled payment"); + Logger.warn("Payment is taking too much time to update its status, status polling timed out."); } }) .pollInterval(1, TimeUnit.SECONDS) @@ -655,7 +657,7 @@ public void onTimeout(TimeoutEvent timeoutEvent) { ApiResponse getPaymentResponse = tlClient.payments().getPayment(paymentId).get(); assertNotError(getPaymentResponse); - return getPaymentResponse.getData().getStatus().equals(Status.SETTLED); + return getPaymentResponse.getData().getStatus().equals(paymentStatus); }); }