From 90273cad8b74bb4129097af0de7caf9c7a875591 Mon Sep 17 00:00:00 2001 From: Andrea Di Lisio Date: Fri, 17 May 2024 17:10:43 +0200 Subject: [PATCH] Adjust settlement/authorisation timeouts in acceptance tests, and review version info loader implementation (#289) --- build.gradle | 2 -- gradle.properties | 2 +- .../java/versioninfo/LibraryInfoLoader.java | 26 ++++++++++++------- .../acceptance/MandatesAcceptanceTests.java | 2 +- .../acceptance/PaymentsAcceptanceTests.java | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index ce5c78d0..f93623d2 100644 --- a/build.gradle +++ b/build.gradle @@ -84,10 +84,8 @@ tasks.register('acceptance-tests', Test) { dependencies { // Utilities - implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4' implementation group: 'org.apache.commons', name: 'commons-configuration2', version: '2.10.1' - // HTTP client def retrofitVersion = '2.9.0' implementation group: 'com.squareup.retrofit2', name: 'retrofit', version: retrofitVersion diff --git a/gradle.properties b/gradle.properties index a109a262..e25f5755 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Main properties group=com.truelayer archivesBaseName=truelayer-java -version=13.0.1 +version=13.0.2 # Artifacts properties sonatype_repository_url=https://s01.oss.sonatype.org/service/local/ diff --git a/src/main/java/com/truelayer/java/versioninfo/LibraryInfoLoader.java b/src/main/java/com/truelayer/java/versioninfo/LibraryInfoLoader.java index 867deadc..0afad576 100644 --- a/src/main/java/com/truelayer/java/versioninfo/LibraryInfoLoader.java +++ b/src/main/java/com/truelayer/java/versioninfo/LibraryInfoLoader.java @@ -1,10 +1,13 @@ package com.truelayer.java.versioninfo; +import static java.util.Objects.requireNonNull; + import com.truelayer.java.Constants; import com.truelayer.java.TrueLayerException; -import org.apache.commons.configuration2.PropertiesConfiguration; -import org.apache.commons.configuration2.builder.fluent.Configurations; -import org.apache.commons.configuration2.ex.ConfigurationException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Properties; /** * Class the loads the version of the library during the client initialization. @@ -15,18 +18,23 @@ public class LibraryInfoLoader { private static final String CONFIG_FILE_PREXIF = "truelayer-java"; public VersionInfo load() { - PropertiesConfiguration libraryVersionProps = getVersionInfoPropertiesFile(); + Properties libraryVersionProps = getVersionInfoProperties(); return VersionInfo.builder() - .libraryName(libraryVersionProps.getString(Constants.VersionInfo.NAME)) - .libraryVersion(libraryVersionProps.getString(Constants.VersionInfo.VERSION)) + .libraryName(libraryVersionProps.getProperty(Constants.VersionInfo.NAME)) + .libraryVersion(libraryVersionProps.getProperty(Constants.VersionInfo.VERSION)) .build(); } - private PropertiesConfiguration getVersionInfoPropertiesFile() { + private Properties getVersionInfoProperties() { try { - return new Configurations().properties(CONFIG_FILE_PREXIF + "." + "version" + ".properties"); - } catch (ConfigurationException e) { + Properties versionInfoProps = new Properties(); + versionInfoProps.load(Files.newInputStream(Paths.get(requireNonNull(getClass() + .getClassLoader() + .getResource(CONFIG_FILE_PREXIF + "." + "version" + ".properties")) + .getPath()))); + return versionInfoProps; + } catch (IOException e) { throw new TrueLayerException("Unable to load library version file", e); } } diff --git a/src/test/java/com/truelayer/java/acceptance/MandatesAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/MandatesAcceptanceTests.java index d727dc14..0cfabf27 100644 --- a/src/test/java/com/truelayer/java/acceptance/MandatesAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/MandatesAcceptanceTests.java @@ -486,7 +486,7 @@ private void authorizeMandate(AuthorizationFlowResponse authorizationFlowRespons private void waitForMandateToBeAuthorized(String mandateId) { await().with() .pollInterval(1, TimeUnit.SECONDS) - .atMost(5, TimeUnit.SECONDS) + .atMost(30, TimeUnit.SECONDS) .until(() -> { // get mandate by id ApiResponse getMandateResponse = diff --git a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java index 6fbbc829..5ab81d16 100644 --- a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java @@ -569,7 +569,7 @@ public void onTimeout(TimeoutEvent timeoutEvent) { } }) .pollInterval(1, TimeUnit.SECONDS) - .atMost(15, TimeUnit.SECONDS) + .atMost(30, TimeUnit.SECONDS) .until(() -> { // get payment by id ApiResponse getPaymentResponse =