Skip to content

Unit test checkout - #2083

Closed
poojah-adyen wants to merge 3 commits into
mainfrom
unit-test-checkout
Closed

poojah-adyen wants to merge 3 commits into
mainfrom
unit-test-checkout

Conversation

@poojah-adyen

Copy link
Copy Markdown
Contributor

Description

Tested scenarios

Fixed issue:

@poojah-adyen
poojah-adyen requested a review from a team as a code owner October 12, 2026 14:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Adyen Checkout API models to version 72, introducing several new models and fields such as CheckoutForwardAccountUpdateResult, CheckoutForwardNetworkTokenResult, PayByBankCADirectDebitDetails, and OPI request/response objects. It also adds new fields like payable in checkout sessions, klarnaNetworkPaymentAccountId in Klarna details, and riskCategory in line items, alongside corresponding unit tests. Feedback is provided to optimize the deserialization logic in CheckoutPaymentMethod.java by replacing the recursive type field search and stream-based enum validation with a direct, more efficient lookup.

Comment on lines +996 to +1000
if (tree.findValue("type") != null) {
typeMatch =
Arrays.stream(PayByBankCADirectDebitDetails.TypeEnum.values())
.anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using tree.findValue("type") recursively searches the entire JSON tree, which can incorrectly match nested type fields from other objects and is less efficient. Additionally, calling TypeEnum.values() and streaming it on every deserialization allocates a new array and stream object, creating unnecessary garbage in a high-throughput path.

Since PayByBankCADirectDebitDetails.TypeEnum currently has only one value, we can perform a direct comparison using tree.get("type") for better safety and performance.

          if (tree.get("type") != null && !tree.get("type").isNull()) {
            typeMatch = PayByBankCADirectDebitDetails.TypeEnum.PAYBYBANK_CA.getValue().equals(tree.get("type").asText());
          }

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants