Repository navigation
Unit test checkout - #2083
Unit test checkout#2083poojah-adyen wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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.
| if (tree.findValue("type") != null) { | ||
| typeMatch = | ||
| Arrays.stream(PayByBankCADirectDebitDetails.TypeEnum.values()) | ||
| .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); | ||
| } |
There was a problem hiding this comment.
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());
}
|



Description
Tested scenarios
Fixed issue: