diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ce04185e..20af8fd8 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -16,6 +16,7 @@ Please select multiple options if required. # Checklist: - [ ] I have updated the `gradle.properties` file with the new version +- [ ] I have updated the `CHANGELOG.md` file with the details of the new versio - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code where necessary diff --git a/.github/workflows/build-test-coverage.yml b/.github/workflows/build-test-coverage.yml index 7805d122..616d806e 100644 --- a/.github/workflows/build-test-coverage.yml +++ b/.github/workflows/build-test-coverage.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ ubuntu-latest ] java-distribution: [ temurin ] - java-version: [ 11, 17, 20, 21 ] + java-version: [ 11, 17, 20, 21, 22, 23 ] runs-on: ${{ matrix.os }} outputs: project_version: ${{ steps.get_project_version.outputs.project_version }} diff --git a/.github/workflows/workflow-examples.yml b/.github/workflows/workflow-examples.yml new file mode 100644 index 00000000..b1e4452a --- /dev/null +++ b/.github/workflows/workflow-examples.yml @@ -0,0 +1,36 @@ +# Workflow that runs on the examples projects. +# Triggered by pushes on the main branch (excluding tags). +# Build, test, run coverage analysis and release to Maven Central a final release. +name: Workflow on example projects + +on: + push: + tags-ignore: + - '**' + +jobs: + build-test: + strategy: + matrix: + project-working-dir: ["quarkus-mvc"] + name: Build and tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./examples/${{ matrix.project-working-dir }} + steps: + - uses: actions/checkout@v4 + - name: Setup JDK + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: 'gradle' + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + - name: Lint + run: ./gradlew spotlessJavaCheck + - name: Build + run: ./gradlew build -x test + - name: Run tests + run: ./gradlew test diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..72dc03eb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,899 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/). + +## [Unreleased] + +## [16.3.1] - 2025-01-10 +### Changed +* Upgrades linting and test libraries +* Upgrades quarkus-mvc test project and introduce CI workflow for that +* Upgrades CI environment +* Introduces CHANGELOG.md file + +### Changed +* feat(ACL-251): Adds method to generate SU+ Authentication URI for FI payments by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/332 + + +## [16.3.0] - 2025-01-08 + +### Added +* feat(ACL-251): Adds method to generate SU+ Authentication URI for FI payments by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/332 + + + +## [16.2.0] - 2024-12-10 + +### Added +* Add search payments providers endpoint + statement reference to merchant account by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/330 + + + +## [16.1.0] - 2024-11-26 + +### Added +* [ACL-226] New HPP link builder with ability to show mandate results, and set wait and/or signup by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/328 + + + +## [16.0.1] - 2024-11-21 + +### Added +* chore(ACL-225): v3 endpoints used for Payments API by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/327 + + + +## [16.0.0] - 2024-10-30 + +### Added +* Merchant accounts updates by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/325 + + + +### Changes +- ⚠️ Breaking: removed `currency` property from `UpdateSweepingRequest` + +## [15.0.0] - 2024-10-18 + +### New features +- Signup+ endpoint to [generate the Auth URI to be used in Finland](https://docs.truelayer.com/reference/generateauthuri) +- Signup+ endpoint to [get identity data associated to a payment, both in UK and Finland](https://docs.truelayer.com/reference/getuserdatabypayment) +- Added the `Authorizing` status returned in the [Create Payment API response](https://docs.truelayer.com/reference/create-payment) +- Added the `scheme_selection` field in the [Create Payout API request](https://docs.truelayer.com/reference/create-payout) + +### Changes +- ⚠️ Breaking: the currency property of the `PaymentDetail` class in now an enum `CurrencyCode` + +## [14.3.0] - 2024-10-16 + +### Added +* [ACL-167] Add sub_merchants support to payouts by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/320 + + + +## [14.2.0] - 2024-09-27 + +### Added +* feat(ACL-195): Adds cancel payment support by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/315 + + + +## [14.1.0] - 2024-09-18 + +### Added +* [ACL-159] Add user_selected scheme selection by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/313 + + + +## [14.0.0] - 2024-09-17 + +### Added +* [ACL-180] Add preselected scheme selection to preselected provider by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/312 +* ⚠️ Breaking ⚠️ : `SchemeSelection` property for `UserSelectedProviderSelection` object has been moved from `com.truelayer.java.payments.entities.schemeselection` package to `com.truelayer.java.payments.entities.schemeselection.userselected` package + + + +## [13.3.0] - 2024-09-11 + +### Added +* [ACL-161] Add risk_assessment field to create payment request by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/311 + + + +## [13.2.0] - 2024-09-10 + +### Added +* feat(ACL-162): supports for verified payins by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/310 + + + +## [13.1.2] - 2024-08-05 + +### Added +* [ACL-174] Improve retry payments acceptance tests by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/303 +* [ACL-175] Fix missing EqualsAndHashCode Lombok annotations by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/304 + + + +## [13.1.0] - 2024-07-25 + +### Added +* [ACL-32] Ownership change by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/299 +* [ACL-138] Add support for retry parameter by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/300 + + + +## [13.0.5] - 2024-06-24 + +### Added +* [EWT-590] Fix mandates acceptance tests by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/296 + + + +## [13.0.4] - 2024-06-13 + +### Added +* [EWT-567] Version info management simplification by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/293 + + + +## [13.0.3] - 2024-05-27 + +### Added +* chore(EWT-561): improved reporting for acceptance tests by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/291 + + + +## [13.0.2] - 2024-05-17 + +### Added +* Adjust settlement/authorisation timeouts in acceptance tests, and review version info loader implementation by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/289 + + + +## [13.0.1] - 2024-05-16 + +### Added +* chore(EWT-560): Dependency updates and improved reporting for failed acceptance tests by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/288 + + + +## [13.0.0] - 2024-04-24 + +### Added +* fix(EWT-543): type change for description field in authorization flow actions objects by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/286 + + + +## [12.0.0] - 2024-04-17 + +### Added +* Added `capabilities.payments.bankTransfer.availability` field to `PaymentsProvider` response entity +* Added `capabilities.mandates.vrpSweeping.availability` field to `PaymentsProvider` response entity +* Added `capabilities.mandates.vrpSweeping.availability` field to `PaymentsProvider` response entity +* ⚠️ **BREAKING** ⚠️ Removed `errorRate` field from `ProviderAvailability` object (used in the new fields defined above and in the already existing `ProviderSelection` authorization flow action + + + +## [11.1.0] - 2024-04-15 + +### Added +* feat(EWT-535): Support for merchant account transactions pagination by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/279 + + + +## [11.0.1] - 2024-02-13 + +### Added +* feat(PAYINS-504): Set Authorization header to `GET v3/payments-providers/{id}` by @tl-facundo-aita in https://github.com/TrueLayer/truelayer-java/pull/270 + + + +## [11.0.0] - 2024-01-08 + +### Added +* added constant for commercial VRP scope: RECURRING_PAYMENTS_COMMERCIAL +* ⚠️ Breaking ⚠️ : refactor the submit provider return response object to support multiple resource types (single payments and mandates) +* tests: refactor the way we do headless auth for payments and mandates in acceptance tests + + + +## [10.3.1] - 2023-12-05 + +### Added +* chore(EWT-359): dependencies and CI updates by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/242 + + + +## [10.3.0] - 2023-11-03 + +### Added +* [EWT-371] Add payment_source property to authorized and failed payment details by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/234 + + + +## [10.2.0] - 2023-10-18 + +### Added +* [DNTT-489] Added settlement_risk to executed and settled payment details response types by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/233 + + + +## [10.1.1] - 2023-10-12 + +### Added +* chore(EWT-358): upgrade to Wiremock 3.X, and more internal deps by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/230 + + + +## [10.1.0] - 2023-10-12 + +### Added +* Adds support for `related_products` object on payment and mandate creation requests +* Adds support for `X-Device-User-Agent` HTTP header on start authorization flow + +PR: https://github.com/TrueLayer/truelayer-java/pull/228 + + +## [10.0.0] - 2023-09-04 + +### Added +- **new**: feature to set explicit global OAuth scopes globally on the client. More on [this Wiki entry](https://github.com/TrueLayer/truelayer-java/wiki/Oauth-access-tokens-management#global-oauth-scopes) +- **changed:** Adapts the /token/connect request to the API specs +- **changed:** Sets explicit scopes on all authenticated requests (relates to #210) +- **changed ⚠️ BREAKING** : changes how caching works and the ICredentialsCache to work with scopes. More on this [wiki page](https://github.com/TrueLayer/truelayer-java/wiki/Oauth-access-tokens-management) + + +## [9.0.1] - 2023-08-24 + +### Added +* [Dependabot]: Bump org.junit.jupiter:junit-jupiter from 5.9.3 to 5.10.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/209 +* [Dependabot]: Bump com.diffplug.spotless from 6.19.0 to 6.20.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/207 +* [Dependabot]: Bump io.freefair.lombok from 8.1.0 to 8.2.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/212 +* [EWT-278] Build also against JDK 20 by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/211 +* [Dependabot]: Bump io.freefair.lombok from 8.2.1 to 8.2.2 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/214 +* fix(EWT-328): improperly formatted datetime string on transactions endpoint by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/216 + + + +## [9.0.0] - 2023-07-19 + +### Added +* [Dependabot]: Bump io.freefair.lombok from 8.0.1 to 8.1.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/206 +* [EWT-306] Fix models inconsistencies by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/208 + +## Breaking change notice +* on `Failed` mandates object, renamed `authorisationFailedAt` property to `failedAt` +* on `Revoked` mandates object, removed `remitter` property + + + +## [8.0.0] - 2023-05-24 + +### Added +* [Dependabot]: Bump org.apache.commons:commons-configuration2 from 2.8.0 to 2.9.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/196 +* [Dependabot]: Bump com.squareup.okhttp3:okhttp from 4.10.0 to 4.11.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/199 +* [Dependabot]: Bump org.junit.jupiter:junit-jupiter from 5.9.2 to 5.9.3 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/200 +* [Dependabot]: Bump com.diffplug.spotless from 6.17.0 to 6.18.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/197 +* [EWT-192] Add support for a limited set of custom HTTP headers by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/204 + +## Breaking change notice +- The ITrueLayerClient interface returns only _Handlers_ interface, as opposed to the previous mix of _Api_ and _Handlers_ interface. +- the old mechanism to set the `X-Forwarded-For` header on the `startAuthorizationFlow` invocations is superseded by the new API. +- The (empty) SubmitConsentRequest object has been removed in favour of a more generic empty request body type. + + + +## [7.0.0] - 2023-05-11 + +## Breaking change notice +`Beneficiary` entity and its extensions (`ExternalAccount`, `PaymentSource`, `BusinessAccount`) have been moved from `com.truelayer.java.merchantaccounts.entities.transactions.beneficiary` to `com.truelayer.java.entities.beneficiary` package. The same entities are referenced from the newly introduced payout entities + +### Added +* [EWT-194] Add payouts support by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/203 + + + +## [6.3.0] - 2023-05-04 + +### Added +* [EWT-191] Add support for custom proxy configurations with authentication by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/202 + + + +## [6.2.0] - 2023-05-03 + +### Added +* [EWT-78] Add payment refunds support by @tl-luca-baggi in https://github.com/TrueLayer/truelayer-java/pull/201 + + + +## [6.1.0] - 2023-03-27 + +### Added +* [Dependabot]: Bump io.github.gradle-nexus.publish-plugin from 1.2.0 to 1.3.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/190 +* [Dependabot]: Bump com.diffplug.spotless from 6.16.0 to 6.17.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/192 +* [EWT-135] feat: adds support for `X-Forwarded-For` HTTP header in start auth flow for single payments by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/195 + + + +## [6.0.1] - 2023-03-06 + +### Added +* [Dependabot]: Bump junit-jupiter from 5.9.1 to 5.9.2 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/179 +* [EWT-99] bump com.diffplug.spotless from 6.12.1 to 6.14.1 + Removes java 8 from our CI matrix by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/183 +* [EWT-73] Updates nexus publish-plugin, gradle wrapper and other internal libraries by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/189 + + + +## [6.0.0] - 2023-01-13 + +### Added +* [EWT-85] fixes existing items returned by the `merchant-accounts/{id}/transactions` endpoint and add support for refunds by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/180 + + + +## [5.0.0] - 2023-01-11 + +### Added +* [Dependabot]: Bump com.diffplug.spotless from 6.12.0 to 6.12.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/177 +* feat(PAYG-1374): Remove user info from get payment and mandate response by @tl-tai-tang in https://github.com/TrueLayer/truelayer-java/pull/178 + +## New Contributors +* @tl-tai-tang made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/178 + + +## [4.2.0] - 2022-12-22 + +### Added +* [Dependabot]: Bump io.freefair.lombok from 6.6 to 6.6.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/174 +* feat: [PAYG-1363] add PLN and NOK currencies by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/176 + + + +## [4.1.0] - 2022-12-20 + +### Added +* Github actions updates by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/173 +* [EWT-79] Default READ timeout reviewed + bugfix for existing custom timeout logic by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/175 + + + +## [4.0.2] - 2022-12-16 + +### Added +* transitive dependencies constraint block to replace previous direct dependencies by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/172 + + + +## [4.0.1] - 2022-12-16 + +### Added +* Bumps dependencies to solve a few vulnerabitities by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/171 + + + +## [4.0.0] - 2022-12-15 + +### Added +* [EWT-63] `scheme_selection` support for single payments by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/170 +* [REC-656] Async and Smart payment retries for recurring payments +* AuthorizationFlow related deprecated objects removal and provider selection DTOs renamed (leftovers) + + + +## [3.2.0] - 2022-12-13 + +### Added +* [REC-740] Get Mandate Constraints + tests by @tl-andrei-sorbun in https://github.com/TrueLayer/truelayer-java/pull/169 + + + +## [3.1.1] - 2022-12-05 + +### Added +* [JSDK-58] Captures Java version in TL-Agent, upgrades Gradle wrapper and CI by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/167 + + + +## [3.1.0] - 2022-12-05 + +### Added +* [JSDK-86] New getters to help with responses interpretations + Dependency updates by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/166 + + + +## [3.0.1] - 2022-12-01 + +### Added +* [EWT-61] feat(observability): User-agent HTTP header replaced with TL-Agent by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/164 + + + +## [3.0.0] - 2022-11-30 + +## Breaking change notice +The `Mandate` and `MandateDetail` types now reference a `Beneficiary` class included in package `com.truelayer.java.mandates.entities.beneficiary` as opposed to the previous `com.truelayer.java.payments.entities.beneficiary`. Moreover, the new `Beneficiary` type for mandates does not contain any a reference field in it. This has now been moved into the `Mandate` type itself. + +### Added +* [Dependabot]: Bump com.diffplug.spotless from 6.11.0 to 6.12.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/163 +* [REC-725] feat(mandate reference): optional mandate reference added by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/162 + + + +## [2.6.0] - 2022-11-17 + +### Added +* [Dependabot]: Bump wiremock-jre8 from 2.34.0 to 2.35.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/158 +* [REC-718] feat(recurring payments): reference added to create payment request for mandates by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/161 + + + +## [2.5.1] - 2022-11-08 + +### Added +* fix: `form` and `consent` action response deserialisation by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/160 + + + +## [2.5.0] - 2022-10-10 + +### Added +* feat: [JSDK-70] get payments provider endpoint by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/156 +* fix: upgraded version to 2.5.0 by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/157 + + + +## [2.4.0] - 2022-10-04 + +### Added +* feat: [PAYG-1169] add status to create payment response by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/155 + + + +## [2.3.0] - 2022-09-28 + +### Added +* [Dependabot]: Bump junit-jupiter from 5.9.0 to 5.9.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/153 +* feat: [PAYG-1148] Add consent and form action support by @Lindronics in https://github.com/TrueLayer/truelayer-java/pull/154 + +## New Contributors +* @Lindronics made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/154 + + +## [2.2.3] - 2022-09-20 + +### Added +* dependencies updates by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/152 + + + +## [2.2.2] - 2022-09-14 + +### Added +* [PAYG-1133] Add extra fields to user object by @tl-wajid-malik in https://github.com/TrueLayer/truelayer-java/pull/148 + +## New Contributors +* @tl-wajid-malik made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/148 + + +## [2.2.1] - 2022-09-14 + +### Added +* [REC-631] reference added to payments into merchant accounts by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/149 + + + +## [2.2.0] - 2022-08-29 + +### Added +* [JSDK-80] Confirmation of Funds by @tl-andrei-sorbun in https://github.com/TrueLayer/truelayer-java/pull/144 + + + +## [2.1.1] - 2022-08-24 + +### Added +* Bump signing library by @tl-andrei-sorbun in https://github.com/TrueLayer/truelayer-java/pull/143 + + + +## [2.1.0] - 2022-08-24 + +### Added +* [Dependabot]: Bump com.diffplug.spotless from 6.9.0 to 6.9.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/139 +* [Dependabot]: Bump com.diffplug.spotless from 6.9.1 to 6.10.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/142 +* [REC-550] Update SDK with new Remitter field by @tl-andrei-sorbun in https://github.com/TrueLayer/truelayer-java/pull/141 + +## New Contributors +* @tl-andrei-sorbun made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/141 + + +## [2.0.4] - 2022-08-23 + +### Added +* [PAYG-920] remove auth flow from authorizing by @tl-facundo-aita in https://github.com/TrueLayer/truelayer-java/pull/133 + + + +## [2.0.3] - 2022-08-04 + +### Added +* [Dependabot]: Bump com.diffplug.spotless from 6.5.2 to 6.9.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/134 +* [Dependabot]: Bump jackson-databind from 2.13.2.2 to 2.13.3 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/117 +* [Dependabot]: Bump junit-jupiter from 5.8.2 to 5.9.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/138 +* [Dependabot]: Bump truelayer-signing from 0.2.0 to 0.2.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/128 +* [Dependabot]: Bump commons-configuration2 from 2.7 to 2.8.0 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/129 +* [Dependabot]: Bump io.freefair.lombok from 6.4.3 to 6.5.0.3 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/130 +* [REC-567] `provider_selection` object on mandate detail DTO by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/137 + + + +## [2.0.2] - 2022-08-03 + +### Added +* [JSDK-82] Javadoc simplification by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/131 +* [JSDK-83] Sample app documentation improvement by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/135 +* [JSDK-64] `metadata` object on payments and mandates DTOs by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/136 + + + +## [2.0.1] - 2022-07-18 + +### Added +* [JSDK-77] Client builder refactor for testability by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/125 + + + +## [2.0.0] - 2022-06-21 + +### Added + +### New features +- Onboards Recurring payments functionalities as per our public docs. +- Adds support for settlement_risk in GET payment by id responses + +### Breaking changes +- `PaymentAuthorizationFlowResponse` renamed to `AuthorizationFlowResponse`, used in both payments and mandates +- Removed `metadata` in `AuthorizationFlowResponse` of type `redirect` +- renamed package for `Provider` class and `providerId` field renamed to `id` in ProviderSelction in authorization flow responses +- `getTransactions` method and `GetTransactionsResponse` renamed to `listTransactions` and `ListTransactionsResonse` respectively. method params simplified with the help of new `ListTransactionsQuery` type +- `getPaymentSources` and `ListPaymentSourcesResponse` renamed to `listPaymentSources` and `ListPaymentSourcesResponse` respectively. method params simplified with the help of new `ListPaymentSourcesQuery` type +- Java 8 `ZonedDateTime` to `replace java.util.Date` + +## New Contributors +* @nico-incubiq made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/121 + + +## [1.1.0] - 2022-05-09 + +### Added +* [JSDK-74] Improved configurability: call timeout, connection pool and request dispatcher by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/115 + + + +## [1.0.0] - 2022-04-13 + +### Added +* [JSDK-60] Support for provider return params by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/96 + + + +## [0.7.5] - 2022-04-06 + +### Added +* [JSDK-66] Bugfix serialization issue by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/103 + + + +## [0.7.4] - 2022-04-05 + +### Added +* [JSDK-63] response DTOs usability improvements by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/100 + + + +## [0.7.3] - 2022-04-05 + +### Added +* Dependabot and CVE-2020-36518 resolution by @dili91 in https://github.com/TrueLayer/truelayer-java/pull/101 + +## New Contributors +* @dili91 made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/101 + + +## [0.7.2] - 2022-04-01 + +### Added +* [JSDK-62] Provider id and scheme id added in GET payment response by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/99 + + + +## [0.7.1] - 2022-04-01 + +### Added +* [JSDK-61] Adds support for unknown properties on response DTOs by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/98 + + + +## [0.7.0] - 2022-03-18 + +### Added +* [JSDK-57] Optional credentials caching + custom pluggable cache by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/94 + + + +## [0.6.0] - 2022-03-15 + +### Added +* [JSDK-55] Custom logging implemented by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/92 + + + +## [0.5.0] - 2022-03-14 + +### Added +* [JSDK-53] Contributing by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/88 +* [JSDK-36] Access token cache by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/83 + + + +## [0.4.14] - 2022-03-11 + +### Added +* [Dependabot]: Bump io.freefair.lombok from 6.2.0 to 6.4.1 by @dependabot in https://github.com/TrueLayer/truelayer-java/pull/86 + + + +## [0.4.13] - 2022-03-08 + +### Added +* [JSDK-50] Update tl signing version by @azanin in https://github.com/TrueLayer/truelayer-java/pull/82 + +## New Contributors +* @azanin made their first contribution in https://github.com/TrueLayer/truelayer-java/pull/82 + + +## [0.4.12] - 2022-03-07 + +### Added +* [JSDK-48] Javadoc and doc improvements by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/81 + + + +## [0.4.11] - 2022-03-04 + +### Added +* [JSDK-9] Public releases and CI changes by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/79 +* [JSDK-9] CI Workflow fixed by @tl-andrea-dilisio in https://github.com/TrueLayer/truelayer-java/pull/80 + + + +## [0.4.10] - 2022-03-01 + + +## [0.4.9] - 2022-03-01 + + + + + + + + + +## [0.4.7] - 2022-02-18 + + + + + + + + + + + +## [0.4.6] - 2022-02-15 + + + + + + + + + +## [0.4.4] - 2022-02-09 + + + + + + + + + + + +## [0.4.3] - 2022-02-04 + + + +## [0.4.2] - 2022-02-04 + + + +## [0.4.1] - 2022-02-03 + + + +## [0.4.0] - 2022-02-03 + + + +## [0.3.9] - 2022-02-03 + + + + + +## [0.3.8] - 2022-02-02 + + + + + +## [0.3.7] - 2022-02-01 + + + + + +## [0.3.6] - 2022-01-27 + + + +## [0.3.5] - 2022-01-26 + + + +## [0.3.4] - 2022-01-25 + + + +## [0.3.3] - 2022-01-25 + + + + + + + + + + + + + + + +## [0.3.1] - 2022-01-24 + + + + + + + + + + + +## [0.3.0] - 2022-01-21 + + + + + + + + + + + + + + + + + + + +## [0.1.7] - 2022-01-18 + + + +## [0.1.6] - 2022-01-18 + + + +## [0.1.5] - 2022-01-18 + + + +## [0.1.4] - 2022-01-17 + + + + + + + + + + + +## [0.1.1] - 2022-01-17 + + + + + + + + + +## [0.1.0] - 2022-01-12 + + + + + +## [0.0.7] - 2022-01-11 + + + + + +## [0.0.5] - 2022-01-10 + + + +## [0.0.4] - 2022-01-10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## [0.0.1] - 2022-01-04 + + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a77f3b55..0438762c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,8 @@ In order to submit changes to the TrueLayer Java project the following steps are 1. Fork the repo and create your branch from `main`. 2. Make sure to add proper tests in case of code changes. 3. Make sure to update the documentation in case of API changes. -4. Once [code linting](https://github.com/TrueLayer/truelayer-java#code-linting) and tests passes, you can raise a pull request. +4. Make sure the project version is changed as needed, as well as the `CHANGELOG` file. +5. Once the CI pipeline passes, you can raise a pull request. ## Code of conduct Make sure you adhere to our [code of conduct](./CODE_OF_CONDUCT.md). diff --git a/build.gradle b/build.gradle index e9de11f1..a81edce1 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { // to publish packages id 'maven-publish' // code linting - id "com.diffplug.spotless" version "6.25.0" + id "com.diffplug.spotless" version "7.0.1" // test coverage id 'jacoco' id 'com.github.kt3k.coveralls' version '2.12.2' @@ -111,7 +111,7 @@ dependencies { testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.4' // Mocking libraries - testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.14.2' + testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.15.2' testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.10.0' // Wait test utility diff --git a/examples/quarkus-mvc/.gitignore b/examples/quarkus-mvc/.gitignore index 285b6bae..ba4fbcc3 100644 --- a/examples/quarkus-mvc/.gitignore +++ b/examples/quarkus-mvc/.gitignore @@ -34,3 +34,8 @@ nb-configuration.xml # Local environment .env + +# Plugin directory +/.quarkus/cli/plugins/ +# TLS Certificates +.certs/ diff --git a/examples/quarkus-mvc/README.md b/examples/quarkus-mvc/README.md index ea0ab8d0..d1dce427 100644 --- a/examples/quarkus-mvc/README.md +++ b/examples/quarkus-mvc/README.md @@ -1,47 +1,62 @@ -# Quarkus MVC example project +# quarkus-mvc -A simple MVC project based on [Quarkus](https://quarkus.io), that comes with a UI to send donations and setup payment mandates -via TrueLayer Payments API. +This project uses Quarkus, the Supersonic Subatomic Java Framework. -![home](./home.png) +If you want to learn more about Quarkus, please visit its website: . +## Running the application in dev mode -## Requirements +You can run your application in dev mode that enables live coding using: -To run the project it is enough to have Java 11 installed with with `JAVA_HOME` environment variable configured appropriately; +```shell script +./gradlew quarkusDev +``` -## Configuration +> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at . -This sample project leverages [Quarkus configuration framework](https://quarkus.io/guides/config) to specify the client -credentials and signing options required to initialise the TrueLayer client. +## Packaging and running the application -In this sample application the client is configured for TrueLayer Sandbox environment. Make sure that you're -using a proper set of Sandbox credentials or switch to your desired environment in [`TrueLayerClientProvider.java`](./src/main/java/com/truelayer/quarkusmvc/TrueLayerClientProvider.java#L33) class. +The application can be packaged using: -The easiest way to setup the project with your credentials is to fill the [application.properties](./src/main/resources/application.properties) file or -set the following environment variables: -- `TL_CLIENT_ID` -- `TL_CLIENT_SECRET` -- `TL_SIGNING_KEY_ID` -- `TL_SIGNING_PRIVATE_KEY_LOCATION` -In addition, make sure to properly configure the redirect URI in the [DonationService.createDonationLink()](./src/main/java/com/truelayer/quarkusmvc/services/DonationService.java#L71) method, so that the value is one of the redirect URIs set as allowed in your Console Application: -```java -return tlClient.hpp().getHostedPaymentPageLink(paymentResponse.getData().getId(), paymentResponse.getData().getResourceToken(), - URI.create("")); +```shell script +./gradlew build ``` -Make sure to whitelist the `` value in your TrueLayer console. +It produces the `quarkus-run.jar` file in the `build/quarkus-app/` directory. +Be aware that it’s not an _über-jar_ as the dependencies are copied into the `build/quarkus-app/lib/` directory. -## Running the application +The application is now runnable using `java -jar build/quarkus-app/quarkus-run.jar`. -To run the application, simply execute the following gradle task from the root directory of this sample project: +If you want to build an _über-jar_, execute the following command: -```shell -./gradlew quarkusDev +```shell script +./gradlew build -Dquarkus.package.jar.type=uber-jar +``` + +The application, packaged as an _über-jar_, is now runnable using `java -jar build/*-runner.jar`. + +## Creating a native executable + +You can create a native executable using: + +```shell script +./gradlew build -Dquarkus.native.enabled=true +``` + +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: + +```shell script +./gradlew build -Dquarkus.native.enabled=true -Dquarkus.native.container-build=true ``` -Alternatively, you can load the project in your favorite IDE and rely on IDE plugins to boot the application. +You can then execute your native executable with: `./build/quarkus-mvc-1.0.0-SNAPSHOT-runner` + +If you want to learn more about building native executables, please consult . + +## Provided Code + +### REST -## Testing the application +Easily start your REST Web Services -Browse to http://localhost:8080/donations or http://localhost:8080/subscriptions \ No newline at end of file +[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources) diff --git a/examples/quarkus-mvc/build.gradle b/examples/quarkus-mvc/build.gradle index 391e257d..0d5043f7 100644 --- a/examples/quarkus-mvc/build.gradle +++ b/examples/quarkus-mvc/build.gradle @@ -1,7 +1,8 @@ plugins { id 'java' id 'io.quarkus' - id "io.freefair.lombok" version "6.6" + id 'io.freefair.lombok' version '8.11' + id "com.diffplug.spotless" version "7.0.1" } repositories { @@ -10,14 +11,17 @@ repositories { } dependencies { - implementation 'io.quarkus:quarkus-resteasy-jackson' implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") implementation 'io.quarkus:quarkus-arc' implementation 'io.quarkus:quarkus-qute' implementation 'io.quarkus:quarkus-resteasy-qute' + implementation 'io.quarkus:quarkus-opentelemetry' - // TL Java BE library - implementation 'com.truelayer:truelayer-java:4.0.0' + // Reference to the library version that's local to this project! + // Check out the main README for instructions on how to install + // the library in your project! + // https://github.com/TrueLayer/truelayer-java?tab=readme-ov-file#stable-releases + implementation 'com.truelayer:truelayer-java' testImplementation 'io.quarkus:quarkus-junit5' testImplementation 'io.rest-assured:rest-assured' @@ -27,10 +31,20 @@ group 'com.truelayer' version '1.0.0-SNAPSHOT' java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } +spotless { + java { + palantirJavaFormat() + } +} + + +test { + systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" +} compileJava { options.encoding = 'UTF-8' options.compilerArgs << '-parameters' diff --git a/examples/quarkus-mvc/gradle.properties b/examples/quarkus-mvc/gradle.properties index 3e6fe4e6..b9e76b76 100644 --- a/examples/quarkus-mvc/gradle.properties +++ b/examples/quarkus-mvc/gradle.properties @@ -1,7 +1,7 @@ -#Gradle properties -#Thu Jan 20 18:17:05 CET 2022 -quarkusPluginVersion=2.6.3.Final -quarkusPlatformArtifactId=quarkus-bom +# Gradle properties + quarkusPluginId=io.quarkus +quarkusPluginVersion=3.17.5 quarkusPlatformGroupId=io.quarkus.platform -quarkusPlatformVersion=2.6.3.Final +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformVersion=3.17.5 diff --git a/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.jar b/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.jar index 7454180f..a4b76b95 100644 Binary files a/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.jar and b/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.properties b/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.properties index 070cb702..df97d72b 100644 --- a/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.properties +++ b/examples/quarkus-mvc/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/quarkus-mvc/gradlew b/examples/quarkus-mvc/gradlew index 1b6c7873..f5feea6d 100755 --- a/examples/quarkus-mvc/gradlew +++ b/examples/quarkus-mvc/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,12 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +134,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +217,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/examples/quarkus-mvc/gradlew.bat b/examples/quarkus-mvc/gradlew.bat index 107acd32..9d21a218 100644 --- a/examples/quarkus-mvc/gradlew.bat +++ b/examples/quarkus-mvc/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/examples/quarkus-mvc/home.png b/examples/quarkus-mvc/home.png deleted file mode 100644 index 09c5ae24..00000000 Binary files a/examples/quarkus-mvc/home.png and /dev/null differ diff --git a/examples/quarkus-mvc/settings.gradle b/examples/quarkus-mvc/settings.gradle index 0f4ced05..f51adf45 100644 --- a/examples/quarkus-mvc/settings.gradle +++ b/examples/quarkus-mvc/settings.gradle @@ -1,11 +1,15 @@ pluginManagement { repositories { - mavenLocal() mavenCentral() gradlePluginPortal() + mavenLocal() } plugins { id "${quarkusPluginId}" version "${quarkusPluginVersion}" } } rootProject.name='quarkus-mvc' + +// Required to reference the local Java library project. +// Not required in projects that are referencing the library via Maven! +includeBuild('../../') \ No newline at end of file diff --git a/examples/quarkus-mvc/src/main/docker/Dockerfile.jvm b/examples/quarkus-mvc/src/main/docker/Dockerfile.jvm index 4f483791..9ebecebb 100644 --- a/examples/quarkus-mvc/src/main/docker/Dockerfile.jvm +++ b/examples/quarkus-mvc/src/main/docker/Dockerfile.jvm @@ -7,26 +7,80 @@ # # Then, build the image with: # -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-webapp-jvm . +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-mvc-jvm . # # Then run the container using: # -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp-jvm +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc-jvm # # If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container # # Then run the container using : # -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp-jvm +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") # ### -FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 +FROM registry.access.redhat.com/ubi8/openjdk-21:1.20 -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +ENV LANGUAGE='en_US:en' -# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" # We make four distinct layers so if there are application changes the library layers can be re-used COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/ @@ -36,6 +90,8 @@ COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/ EXPOSE 8080 USER 185 +ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/examples/quarkus-mvc/src/main/docker/Dockerfile.legacy-jar b/examples/quarkus-mvc/src/main/docker/Dockerfile.legacy-jar index 083d58de..54c4df25 100644 --- a/examples/quarkus-mvc/src/main/docker/Dockerfile.legacy-jar +++ b/examples/quarkus-mvc/src/main/docker/Dockerfile.legacy-jar @@ -3,35 +3,91 @@ # # Before building the container image run: # -# ./gradlew build -Dquarkus.package.type=legacy-jar +# ./gradlew build -Dquarkus.package.jar.type=legacy-jar # # Then, build the image with: # -# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus-webapp-legacy-jar . +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus-mvc-legacy-jar . # # Then run the container using: # -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp-legacy-jar +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc-legacy-jar # # If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container # # Then run the container using : # -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp-legacy-jar +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") # ### -FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 +FROM registry.access.redhat.com/ubi8/openjdk-21:1.20 -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +ENV LANGUAGE='en_US:en' -# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" COPY build/lib/* /deployments/lib/ COPY build/*-runner.jar /deployments/quarkus-run.jar EXPOSE 8080 USER 185 +ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" -ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/examples/quarkus-mvc/src/main/docker/Dockerfile.native b/examples/quarkus-mvc/src/main/docker/Dockerfile.native index 309c5505..16856a00 100644 --- a/examples/quarkus-mvc/src/main/docker/Dockerfile.native +++ b/examples/quarkus-mvc/src/main/docker/Dockerfile.native @@ -1,20 +1,20 @@ #### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. # # Before building the container image run: # -# ./gradlew build -Dquarkus.package.type=native +# ./gradlew build -Dquarkus.native.enabled=true # # Then, build the image with: # -# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-webapp . +# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-mvc . # # Then run the container using: # -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc # ### -FROM quay.io/quarkus/quarkus-micro-image:1.0 +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10 WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ @@ -24,4 +24,4 @@ COPY --chown=1001:root build/*-runner /work/application EXPOSE 8080 USER 1001 -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/examples/quarkus-mvc/src/main/docker/Dockerfile.native-distroless b/examples/quarkus-mvc/src/main/docker/Dockerfile.native-distroless deleted file mode 100644 index f6338486..00000000 --- a/examples/quarkus-mvc/src/main/docker/Dockerfile.native-distroless +++ /dev/null @@ -1,23 +0,0 @@ -#### -# This Dockerfile is used in order to build a distroless container that runs the Quarkus application in native (no JVM) mode -# -# Before building the container image run: -# -# ./gradlew build -Dquarkus.package.type=native -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native-distroless -t quarkus/quarkus-webapp . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/quarkus-webapp -# -### -FROM quay.io/quarkus/quarkus-distroless-image:1.0 -COPY build/*-runner /application - -EXPOSE 8080 -USER nonroot - -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/examples/quarkus-mvc/src/main/docker/Dockerfile.native-micro b/examples/quarkus-mvc/src/main/docker/Dockerfile.native-micro new file mode 100644 index 00000000..13e846f3 --- /dev/null +++ b/examples/quarkus-mvc/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,30 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./gradlew build -Dquarkus.native.enabled=true +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/quarkus-mvc . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/quarkus-mvc +# +### +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root build/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/TrueLayerClientProvider.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/TrueLayerClientProvider.java index 7b3eef9d..072034ed 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/TrueLayerClientProvider.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/TrueLayerClientProvider.java @@ -1,14 +1,15 @@ package com.truelayer.quarkusmvc; import com.truelayer.java.*; +import jakarta.enterprise.context.ApplicationScoped; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import lombok.SneakyThrows; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.logging.Logger; -import javax.inject.Singleton; -import java.nio.file.Files; -import java.nio.file.Path; - +@ApplicationScoped public class TrueLayerClientProvider { @ConfigProperty(name = "tl.client.id") @@ -25,18 +26,15 @@ public class TrueLayerClientProvider { private static final Logger LOG = Logger.getLogger(TrueLayerClientProvider.class); - @Singleton + @ApplicationScoped @SneakyThrows - public ITrueLayerClient producer(){ - + public ITrueLayerClient producer() throws IOException { return TrueLayerClient.New() .environment(Environment.sandbox()) - .clientCredentials( - ClientCredentials.builder() - .clientId(clientId) - .clientSecret(clientSecret) - .build() - ) + .clientCredentials(ClientCredentials.builder() + .clientId(clientId) + .clientSecret(clientSecret) + .build()) .signingOptions(SigningOptions.builder() .keyId(signingKeyId) .privateKey(Files.readAllBytes(Path.of(signingPrivateKeyLocation))) diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/DonationsController.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/DonationsController.java index 842c2b35..8826ccc8 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/DonationsController.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/DonationsController.java @@ -1,19 +1,25 @@ package com.truelayer.quarkusmvc.controllers; +import com.truelayer.java.ITrueLayerClient; import com.truelayer.quarkusmvc.models.DonationRequest; import com.truelayer.quarkusmvc.services.IDonationService; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateInstance; +import jakarta.inject.Inject; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import org.jboss.resteasy.annotations.Form; -import javax.inject.Inject; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - @Path("/donations") +@RequiredArgsConstructor public class DonationsController { + private final ITrueLayerClient trueLayerClient; + @Inject Template donations; @@ -25,20 +31,33 @@ public class DonationsController { @GET @Produces(MediaType.TEXT_HTML) - public TemplateInstance home(){ + public TemplateInstance home() { return donations.instance(); } + @GET + @Path("/test") + @SneakyThrows + public Response test() { + var token = trueLayerClient.auth().getOauthToken(List.of("payments")).get(); + + if (token.isError()) { + return Response.serverError().build(); + } + + return Response.ok("token expires in " + token.getData().getExpiresIn()).build(); + } + @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - public Response donate(@Form DonationRequest donationRequest){ + public Response donate(@Form DonationRequest donationRequest) { var hppUrl = donationService.createDonationLink(donationRequest); return Response.seeOther(hppUrl).build(); } @GET @Path("/callback") - public TemplateInstance callback(@QueryParam("payment_id") String paymentId){ + public TemplateInstance callback(@QueryParam("payment_id") String paymentId) { var donation = donationService.getDonationById(paymentId); return callback.data(donation); } diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/SubscriptionsController.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/SubscriptionsController.java index 1b27c918..5c8ae944 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/SubscriptionsController.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/controllers/SubscriptionsController.java @@ -4,13 +4,12 @@ import com.truelayer.quarkusmvc.services.ISubscriptionService; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateInstance; +import jakarta.inject.Inject; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import org.jboss.resteasy.annotations.Form; -import javax.inject.Inject; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - @Path("/subscriptions") public class SubscriptionsController { @@ -25,20 +24,20 @@ public class SubscriptionsController { @GET @Produces(MediaType.TEXT_HTML) - public TemplateInstance subscriptions(){ + public TemplateInstance subscriptions() { return subscriptions.instance(); } @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - public Response subscribe(@Form SubscriptionRequest subscriptionRequest){ + public Response subscribe(@Form SubscriptionRequest subscriptionRequest) { var hppUrl = subscriptionService.createSubscriptionLink(subscriptionRequest); return Response.seeOther(hppUrl).build(); } @GET @Path("/callback") - public TemplateInstance callback(@QueryParam("mandate_id") String mandateId){ + public TemplateInstance callback(@QueryParam("mandate_id") String mandateId) { // subs otherwise var subscription = subscriptionService.getSubscriptionById(mandateId); return callback.data(subscription); diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/DonationRequest.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/DonationRequest.java index dc3f8c02..fa5fe4f4 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/DonationRequest.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/DonationRequest.java @@ -1,15 +1,16 @@ package com.truelayer.quarkusmvc.models; +import jakarta.ws.rs.FormParam; import lombok.Data; -import javax.ws.rs.FormParam; - @Data public class DonationRequest { @FormParam("name") private String name; + @FormParam("amount") private int amount; + @FormParam("email") private String email; } diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/SubscriptionRequest.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/SubscriptionRequest.java index 83279111..e231f89a 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/SubscriptionRequest.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/models/SubscriptionRequest.java @@ -1,9 +1,8 @@ package com.truelayer.quarkusmvc.models; +import jakarta.ws.rs.FormParam; import lombok.Data; -import javax.ws.rs.FormParam; - @Data public class SubscriptionRequest { @FormParam("amount") diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/DonationService.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/DonationService.java index babd7a9a..a3986188 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/DonationService.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/DonationService.java @@ -4,20 +4,17 @@ import com.truelayer.java.entities.CurrencyCode; import com.truelayer.java.entities.User; import com.truelayer.java.entities.accountidentifier.SortCodeAccountNumberAccountIdentifier; +import com.truelayer.java.payments.entities.CreatePaymentRequest; import com.truelayer.java.payments.entities.beneficiary.ExternalAccount; import com.truelayer.java.payments.entities.paymentmethod.BankTransfer; import com.truelayer.java.payments.entities.providerselection.ProviderSelection; -import com.truelayer.quarkusmvc.models.DonationResult; import com.truelayer.quarkusmvc.models.DonationRequest; +import com.truelayer.quarkusmvc.models.DonationResult; +import jakarta.enterprise.context.ApplicationScoped; +import java.net.URI; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; -import javax.enterprise.context.ApplicationScoped; -import java.net.URI; - -import static com.truelayer.java.payments.entities.CreatePaymentRequest.builder; - - @ApplicationScoped @RequiredArgsConstructor public class DonationService implements IDonationService { @@ -27,9 +24,10 @@ public class DonationService implements IDonationService { @SneakyThrows @Override public DonationResult getDonationById(String id) { + var payment = tlClient.payments().getPayment(id).get(); - if(payment.isError()){ + if (payment.isError()) { throw new RuntimeException(String.format("get payment by id error: %s", payment.getError())); } @@ -42,7 +40,7 @@ public DonationResult getDonationById(String id) { @SneakyThrows @Override public URI createDonationLink(DonationRequest req) { - var paymentRequest = builder() + var paymentRequest = CreatePaymentRequest.builder() .amountInMinor(req.getAmount()) .currency(CurrencyCode.GBP) .paymentMethod(BankTransfer.builder() @@ -56,21 +54,19 @@ public URI createDonationLink(DonationRequest req) { .reference("test donation") .build()) .build()) - .user(User.builder() - .name(req.getName()) - .email(req.getEmail()) - .build()) + .user(User.builder().name(req.getName()).email(req.getEmail()).build()) .build(); - var paymentResponse = tlClient.payments() - .createPayment(paymentRequest) - .get(); + var paymentResponse = tlClient.payments().createPayment(paymentRequest).get(); - if(paymentResponse.isError()){ + if (paymentResponse.isError()) { throw new RuntimeException(String.format("create payment error: %s", paymentResponse.getError())); } - return tlClient.hpp().getHostedPaymentPageLink(paymentResponse.getData().getId(), paymentResponse.getData().getResourceToken(), - URI.create("http://localhost:8080/donations/callback")); + return tlClient.hpp() + .getHostedPaymentPageLink( + paymentResponse.getData().getId(), + paymentResponse.getData().getResourceToken(), + URI.create("http://localhost:8080/donations/callback")); } } diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/IDonationService.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/IDonationService.java index a789f6f0..da32f4cd 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/IDonationService.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/IDonationService.java @@ -1,8 +1,7 @@ package com.truelayer.quarkusmvc.services; -import com.truelayer.quarkusmvc.models.DonationResult; import com.truelayer.quarkusmvc.models.DonationRequest; - +import com.truelayer.quarkusmvc.models.DonationResult; import java.net.URI; public interface IDonationService { diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/ISubscriptionService.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/ISubscriptionService.java index e8d441af..7b02f8d7 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/ISubscriptionService.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/ISubscriptionService.java @@ -1,10 +1,7 @@ package com.truelayer.quarkusmvc.services; -import com.truelayer.quarkusmvc.models.DonationRequest; -import com.truelayer.quarkusmvc.models.DonationResult; import com.truelayer.quarkusmvc.models.SubscriptionRequest; import com.truelayer.quarkusmvc.models.SubscriptionResult; - import java.net.URI; public interface ISubscriptionService { diff --git a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/SubscriptionService.java b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/SubscriptionService.java index ca0c09f6..b6fc9f8e 100644 --- a/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/SubscriptionService.java +++ b/examples/quarkus-mvc/src/main/java/com/truelayer/quarkusmvc/services/SubscriptionService.java @@ -1,5 +1,7 @@ package com.truelayer.quarkusmvc.services; +import static com.truelayer.java.mandates.entities.Constraints.PeriodicLimits.Limit.PeriodAlignment.CALENDAR; + import com.truelayer.java.ITrueLayerClient; import com.truelayer.java.entities.CurrencyCode; import com.truelayer.java.entities.User; @@ -15,19 +17,15 @@ import com.truelayer.java.payments.entities.providerselection.ProviderSelection; import com.truelayer.quarkusmvc.models.SubscriptionRequest; import com.truelayer.quarkusmvc.models.SubscriptionResult; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; - -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; import java.net.URI; -import java.util.Collections; import java.util.UUID; - -import static com.truelayer.java.mandates.entities.Constraints.PeriodicLimits.Limit.PeriodAlignment.CALENDAR; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; @ApplicationScoped @RequiredArgsConstructor -public class SubscriptionService implements ISubscriptionService{ +public class SubscriptionService implements ISubscriptionService { public static final String PROVIDER_ID = "ob-uki-mock-bank"; @@ -68,7 +66,7 @@ public URI createSubscriptionLink(SubscriptionRequest req) { .build(); var mandate = trueLayerClient.mandates().createMandate(createMandateReq).get(); - if(mandate.isError()){ + if (mandate.isError()) { throw new RuntimeException(String.format("create mandate error: %s", mandate.getError())); } @@ -80,30 +78,40 @@ public URI createSubscriptionLink(SubscriptionRequest req) { .build()) .build(); - ApiResponse startAuthorizationFlowResponse = trueLayerClient.mandates() + ApiResponse startAuthorizationFlowResponse = trueLayerClient + .mandates() .startAuthorizationFlow(mandate.getData().getId(), startAuthorizationFlowRequest) .get(); - if(startAuthorizationFlowResponse.isError()){ - throw new RuntimeException(String.format("start auth flow error: %s", - startAuthorizationFlowResponse.getError())); + if (startAuthorizationFlowResponse.isError()) { + throw new RuntimeException( + String.format("start auth flow error: %s", startAuthorizationFlowResponse.getError())); } - if(startAuthorizationFlowResponse.getData().isAuthorizationFailed()){ - throw new RuntimeException(String.format("start auth flow failed: %s", - startAuthorizationFlowResponse.getData().asAuthorizationFailed().getFailureReason())); + if (startAuthorizationFlowResponse.getData().isAuthorizationFailed()) { + throw new RuntimeException(String.format( + "start auth flow failed: %s", + startAuthorizationFlowResponse + .getData() + .asAuthorizationFailed() + .getFailureReason())); } - return startAuthorizationFlowResponse.getData() + return startAuthorizationFlowResponse + .getData() .asAuthorizing() .getAuthorizationFlow() - .getActions().getNext().asRedirect().getUri(); + .getActions() + .getNext() + .asRedirect() + .getUri(); } @SneakyThrows @Override public SubscriptionResult getSubscriptionById(String id) { - ApiResponse getMandateById = trueLayerClient.mandates().getMandate(id).get(); + ApiResponse getMandateById = + trueLayerClient.mandates().getMandate(id).get(); return SubscriptionResult.builder() .status(getMandateById.getData().getStatus().getStatus()) diff --git a/examples/quarkus-mvc/src/main/resources/application.properties b/examples/quarkus-mvc/src/main/resources/application.properties index e2f1d8e1..dc27bc33 100644 --- a/examples/quarkus-mvc/src/main/resources/application.properties +++ b/examples/quarkus-mvc/src/main/resources/application.properties @@ -4,3 +4,9 @@ tl.client.id=to-set tl.client.secret=to-set tl.signing.key_id=to-set tl.signing.private_key_location=to-set + +quarkus.otel.trace.enabled=true +quarkus.otel.metrics.enabled=true +quarkus.otel.logs.enabled=true +quarkus.application.name=quarkus-mvc +quarkus.otel.exporter.otlp.endpoint=http://localhost:4317 \ No newline at end of file diff --git a/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerIT.java b/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerIT.java deleted file mode 100644 index dee189a3..00000000 --- a/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerIT.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.truelayer.quarkusmvc; - -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -public class NativeDonateControllerIT extends DonateControllerTest { - // Execute the same tests but in native mode. -} \ No newline at end of file diff --git a/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerTest.java b/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerTest.java new file mode 100644 index 00000000..2ff9af4f --- /dev/null +++ b/examples/quarkus-mvc/src/native-test/java/com/truelayer/quarkusmvc/NativeDonateControllerTest.java @@ -0,0 +1,8 @@ +package com.truelayer.quarkusmvc; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class NativeDonateControllerTest extends DonateControllerTest { + // Execute the same tests but in packaged mode. +} diff --git a/examples/quarkus-mvc/src/test/java/com/truelayer/quarkusmvc/DonateControllerTest.java b/examples/quarkus-mvc/src/test/java/com/truelayer/quarkusmvc/DonateControllerTest.java index 1774f623..efbcbc8a 100644 --- a/examples/quarkus-mvc/src/test/java/com/truelayer/quarkusmvc/DonateControllerTest.java +++ b/examples/quarkus-mvc/src/test/java/com/truelayer/quarkusmvc/DonateControllerTest.java @@ -1,13 +1,14 @@ package com.truelayer.quarkusmvc; +import static io.restassured.RestAssured.given; + import io.quarkus.test.junit.QuarkusTest; -import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; - @QuarkusTest -public class DonateControllerTest { - // todo -} \ No newline at end of file +class DonateControllerTest { + @Test + void testDonateEndpoint() { + given().when().get("/donations").then().statusCode(200); + } +} diff --git a/gradle.properties b/gradle.properties index 7a39c856..f317110b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Main properties group=com.truelayer archivesBaseName=truelayer-java -version=16.3.0 +version=16.3.1 # Artifacts properties sonatype_repository_url=https://s01.oss.sonatype.org/service/local/