From eaee5125eb81c12d21bd1308f184099433c15b1d Mon Sep 17 00:00:00 2001 From: ashwani Date: Thu, 8 Oct 2026 09:23:43 +0200 Subject: [PATCH 1/2] Add Test Cases for Transactionwebhooks (PR #2071) --- .../webhooks/BalancePlatformWebhooksTest.java | 36 ++++++++++++++++ ...tform-transaction-created-issued-card.json | 42 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/test/resources/mocks/notification/balancePlatform-transaction-created-issued-card.json diff --git a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java index 678622eaa..35bc9865d 100644 --- a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java +++ b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java @@ -17,6 +17,7 @@ import com.adyen.model.reportwebhooks.ReportNotificationRequest; import com.adyen.model.reportwebhooks.ReportWebhooksHandler; import com.adyen.model.transactionwebhooks.BankCategoryData; +import com.adyen.model.transactionwebhooks.IssuedCard; import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4; import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler; import com.adyen.model.transferwebhooks.BalanceMutation; @@ -280,6 +281,41 @@ public void testTransactionWebhookBankCategoryDataParsing() { Assertions.assertEquals(BankCategoryData.PriorityEnum.REGULAR, bankCategoryData.getPriority()); } + /** + * Verifies that a transaction.created webhook for an issued card is fully deserialized: the card + * category data, including the network variant of the payment network used for the transaction. + */ + @Test + public void testTransactionWebhookIssuedCardCategoryDataParsing() { + String json = + getFileContents("mocks/notification/balancePlatform-transaction-created-issued-card.json"); + TransactionWebhooksHandler webhookHandler = new TransactionWebhooksHandler(json); + Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent()); + TransactionNotificationRequestV4 request = + webhookHandler.getTransactionNotificationRequestV4().get(); + Assertions.assertEquals("EVJN00000000000000000000000004USD", request.getData().getId()); + + IssuedCard issuedCard = request.getData().getTransfer().getCategoryData().getIssuedCard(); + Assertions.assertNotNull(issuedCard); + Assertions.assertEquals(IssuedCard.TypeEnum.ISSUEDCARD, issuedCard.getType()); + Assertions.assertEquals( + IssuedCard.NetworkVariantEnum.MAESTRO_US, issuedCard.getNetworkVariant()); + } + + /** + * Verifies the wire-value mapping of the card network variant enum and its forward + * compatibility: known values deserialize to the matching enum constant, while values not yet + * known to this library deserialize to null instead of throwing an exception. + */ + @Test + public void testIssuedCardNetworkVariantDeserialization() { + Assertions.assertEquals( + "maestro_us", IssuedCard.NetworkVariantEnum.MAESTRO_US.getValue()); + Assertions.assertEquals( + IssuedCard.NetworkVariantEnum.VISA, IssuedCard.NetworkVariantEnum.fromValue("visa")); + Assertions.assertNull(IssuedCard.NetworkVariantEnum.fromValue("some_future_network")); + } + @Test public void testNegativeBalanceCompensationWarning() { String json = diff --git a/src/test/resources/mocks/notification/balancePlatform-transaction-created-issued-card.json b/src/test/resources/mocks/notification/balancePlatform-transaction-created-issued-card.json new file mode 100644 index 000000000..1d4526037 --- /dev/null +++ b/src/test/resources/mocks/notification/balancePlatform-transaction-created-issued-card.json @@ -0,0 +1,42 @@ +{ + "data": { + "id": "EVJN00000000000000000000000004USD", + "amount": { + "value": -2500, + "currency": "USD" + }, + "status": "booked", + "transfer": { + "categoryData": { + "type": "issuedCard", + "authorisationType": "pos", + "networkVariant": "maestro_us", + "panEntryMode": "chip", + "processingType": "pos" + }, + "id": "3JNC3O5ZVFLLGV4C", + "reference": "Your internal reference for the transfer" + }, + "valueDate": "2023-08-11T16:19:35+02:00", + "bookingDate": "2023-08-11T16:31:02+02:00", + "creationDate": "2023-08-11T16:19:35+02:00", + "description": "Card authorisation", + "accountHolder": { + "id": "AH00000000000000000000001", + "reference": "Your reference for the account holder", + "description": "Your description of the account holder" + }, + "balanceAccount": { + "id": "BA00000000000000000000001", + "description": "Your description of the balance account from where the amount is debited." + }, + "paymentInstrument": { + "id": "PI00000000000000000000001", + "description": "Your description of the payment instrument" + }, + "balancePlatform": "YOUR_BALANCE_PLATFORM" + }, + "environment": "test", + "timestamp": "2023-08-11T16:16:35+02:00", + "type": "balancePlatform.transaction.created" +} From d3ff0de9833647f123bcd8b611c6fe181ccea0e5 Mon Sep 17 00:00:00 2001 From: ashwani Date: Thu, 8 Oct 2026 09:36:20 +0200 Subject: [PATCH 2/2] Fix Apply gemini comment --- .../webhooks/BalancePlatformWebhooksTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java index 35bc9865d..2d08eab68 100644 --- a/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java +++ b/src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java @@ -290,9 +290,10 @@ public void testTransactionWebhookIssuedCardCategoryDataParsing() { String json = getFileContents("mocks/notification/balancePlatform-transaction-created-issued-card.json"); TransactionWebhooksHandler webhookHandler = new TransactionWebhooksHandler(json); - Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent()); - TransactionNotificationRequestV4 request = - webhookHandler.getTransactionNotificationRequestV4().get(); + Optional requestOptional = + webhookHandler.getTransactionNotificationRequestV4(); + Assertions.assertTrue(requestOptional.isPresent()); + TransactionNotificationRequestV4 request = requestOptional.get(); Assertions.assertEquals("EVJN00000000000000000000000004USD", request.getData().getId()); IssuedCard issuedCard = request.getData().getTransfer().getCategoryData().getIssuedCard(); @@ -303,14 +304,13 @@ public void testTransactionWebhookIssuedCardCategoryDataParsing() { } /** - * Verifies the wire-value mapping of the card network variant enum and its forward - * compatibility: known values deserialize to the matching enum constant, while values not yet - * known to this library deserialize to null instead of throwing an exception. + * Verifies the wire-value mapping of the card network variant enum and its forward compatibility: + * known values deserialize to the matching enum constant, while values not yet known to this + * library deserialize to null instead of throwing an exception. */ @Test public void testIssuedCardNetworkVariantDeserialization() { - Assertions.assertEquals( - "maestro_us", IssuedCard.NetworkVariantEnum.MAESTRO_US.getValue()); + Assertions.assertEquals("maestro_us", IssuedCard.NetworkVariantEnum.MAESTRO_US.getValue()); Assertions.assertEquals( IssuedCard.NetworkVariantEnum.VISA, IssuedCard.NetworkVariantEnum.fromValue("visa")); Assertions.assertNull(IssuedCard.NetworkVariantEnum.fromValue("some_future_network"));