Skip to content

Commit c7150fe

Browse files
committed
Adding test for transaction webhook serialization/deserialization
1 parent 6c90cc7 commit c7150fe

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.adyen.model.negativebalancewarningwebhooks.NegativeBalanceWarningWebhooksHandler;
1717
import com.adyen.model.reportwebhooks.ReportNotificationRequest;
1818
import com.adyen.model.reportwebhooks.ReportWebhooksHandler;
19+
import com.adyen.model.transactionwebhooks.BankCategoryData;
1920
import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4;
2021
import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler;
2122
import com.adyen.model.transferwebhooks.BalanceMutation;
@@ -259,6 +260,24 @@ public void testTransactionWebhookParsing() {
259260
Assertions.assertEquals("EVJN42272224222B5JB8BRC84N686ZEUR", request.getData().getId());
260261
}
261262

263+
@Test
264+
public void testTransactionWebhookBankCategoryDataParsing() {
265+
String json =
266+
getFileContents(
267+
"mocks/notification/balancePlatform-transaction-created-bank-category.json");
268+
TransactionWebhooksHandler webhookHandler = new TransactionWebhooksHandler(json);
269+
Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent());
270+
TransactionNotificationRequestV4 request =
271+
webhookHandler.getTransactionNotificationRequestV4().get();
272+
Assertions.assertEquals("EVJN00000000000000000000000003EUR", request.getData().getId());
273+
274+
BankCategoryData bankCategoryData =
275+
request.getData().getTransfer().getCategoryData().getBankCategoryData();
276+
Assertions.assertNotNull(bankCategoryData);
277+
Assertions.assertEquals(BankCategoryData.TypeEnum.BANK, bankCategoryData.getType());
278+
Assertions.assertEquals(BankCategoryData.PriorityEnum.REGULAR, bankCategoryData.getPriority());
279+
}
280+
262281
@Test
263282
public void testNegativeBalanceCompensationWarning() {
264283
String json =
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"data": {
3+
"id": "EVJN00000000000000000000000003EUR",
4+
"amount": {
5+
"value": -10000,
6+
"currency": "EUR"
7+
},
8+
"status": "booked",
9+
"transfer": {
10+
"categoryData": {
11+
"priority": "regular",
12+
"type": "bank"
13+
},
14+
"id": "3JNC3O5ZVFLLGV4B",
15+
"reference": " Your internal reference for the transfer"
16+
},
17+
"valueDate": "2023-08-11T16:19:35+02:00",
18+
"bookingDate": "2023-08-11T16:31:02+02:00",
19+
"creationDate": "2023-08-11T16:19:35+02:00",
20+
"description": "Your description of the transfer",
21+
"referenceForBeneficiary": "Your reference sent to the beneficiary of the transfer",
22+
"accountHolder": {
23+
"id": "AH00000000000000000000001",
24+
"reference": "Your reference for the account holder",
25+
"description": "Your description of the account holder"
26+
},
27+
"balanceAccount": {
28+
"id": "BA00000000000000000000001",
29+
"description": "Your description of the balance account from where the amount is debited."
30+
},
31+
"paymentInstrument": {
32+
"id": "PI00000000000000000000001",
33+
"description": "Your description of the payment instrument"
34+
},
35+
"balancePlatform": "YOUR_BALANCE_PLATFORM"
36+
},
37+
"environment": "test",
38+
"timestamp": "2023-08-11T16:16:35+02:00",
39+
"type": "balancePlatform.transaction.created"
40+
}

0 commit comments

Comments
 (0)