Skip to content

Unit Test for Transactionwebhooks (PR #2071) - #2082

Open
ashwaniarya-adyen wants to merge 2 commits into
mainfrom
test-case-transactionwebhooks
Open

ashwaniarya-adyen wants to merge 2 commits into
mainfrom
test-case-transactionwebhooks

Conversation

@ashwaniarya-adyen

Copy link
Copy Markdown
Contributor

Adds test coverage for the transactionwebhooks IssuedCard model (#2071).

 •  New mock balancePlatform-transaction-created-issued-card.json: a balancePlatform.transaction.created webhook with issued card category data
 •  testTransactionWebhookIssuedCardCategoryDataParsing: verifies deserialization of the card category data, including the networkVariant field
 •  testIssuedCardNetworkVariantDeserialization: verifies enum wire-value mapping and that unknown values deserialize to null instead of throwing

@ashwaniarya-adyen
ashwaniarya-adyen requested a review from a team as a code owner October 8, 2026 07:25

@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 adds test coverage for the deserialization of transaction webhooks related to issued cards. It introduces a mock JSON payload representing a transaction created webhook and adds two unit tests in BalancePlatformWebhooksTest.java to verify the parsing of card category data and the forward compatibility of the card network variant enum. The review feedback suggests optimizing the test by storing the result of webhookHandler.getTransactionNotificationRequestV4() in an Optional to avoid redundant JSON deserialization.

Comment on lines +293 to +295
Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent());
TransactionNotificationRequestV4 request =
webhookHandler.getTransactionNotificationRequestV4().get();

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

Calling webhookHandler.getTransactionNotificationRequestV4() twice triggers redundant JSON deserialization of the payload. It is more efficient and consistent with other tests in this class to store the result in an Optional first.

Suggested change
Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent());
TransactionNotificationRequestV4 request =
webhookHandler.getTransactionNotificationRequestV4().get();
Optional<TransactionNotificationRequestV4> requestOptional = webhookHandler.getTransactionNotificationRequestV4();
Assertions.assertTrue(requestOptional.isPresent());
TransactionNotificationRequestV4 request = requestOptional.get();

@ashwaniarya-adyen ashwaniarya-adyen self-assigned this Oct 8, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@ashwaniarya-adyen ashwaniarya-adyen changed the title Add Test Cases for Transactionwebhooks (PR #2071) Unit Test Cases for Transactionwebhooks (PR #2071) Oct 8, 2026
@ashwaniarya-adyen ashwaniarya-adyen changed the title Unit Test Cases for Transactionwebhooks (PR #2071) Unit Test for Transactionwebhooks (PR #2071) Oct 8, 2026

This branch has not been deployed

No deployments
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.

1 participant