Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces regional base URL support for the Adyen Device API, enabling the construction of region-specific live URLs based on configuration. The feedback highlights a logic issue where early returns prevent generic URL transformations, suggests escaping dots in regex strings for accuracy, and identifies a potential misconfiguration for the India region. Furthermore, it recommends simplifying the test suite by removing unnecessary reflection for accessing protected fields within the same package.
src/test/java/com/adyen/service/clouddevice/CloudDeviceApiTest.java
Outdated
Show resolved
Hide resolved
…ccess Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…locks Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
| url.replaceFirst( | ||
| "https://device-api-test.adyen.com", | ||
| String.format( | ||
| "https://device-api-live-%s.adyen.com", |
There was a problem hiding this comment.
@gcatanese so EU endpoints don't have a region suffix but anything non-EU does?
| } | ||
|
|
||
| @Test | ||
| public void testDeviceApiLiveUrlEuRegion() { |
There was a problem hiding this comment.
For the region tests, it might be more maintainable if we use @ParametrizedTest with an @EnumSource
There was a problem hiding this comment.
I have used @MethodSource as it seems more suitable than @EnumSource because there is no enum for EU scenario. The method deviceApiRegionToLiveUrl covers all cases and makes it very intuitive.
…ethodSource Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Summary
Extends the
createBaseURLlogic inService.javato properly handle the Cloud Device API base URL when switching from test to live environments.Previously, the generic
-testto-livereplacement was applied to all URLs. The Device API uses a different URL pattern (device-api-test.adyen.com) that requires region-aware routing in live environments.Changes
Service.java: Added a condition to detect Device API URLs (device-api-) and replace the test URL with the correct live URL based onterminalApiRegion:https://device-api-live.adyen.comhttps://device-api-live-{region}.adyen.comServiceTest.java: Added unit tests covering all region cases (default/EU, AU, US, APSE) and the test environment passthrough.CloudDeviceApiTest.java: Added integration-style tests verifying the resolvedbaseURLfield onCloudDeviceApifor various environment/region combinations.