Skip to content

Commit 6cbf2da

Browse files
committed
Adding test for transaction webhook serialization/deserialization
1 parent 96a7949 commit 6cbf2da

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.InterchangeData;
@@ -256,6 +257,24 @@ public void testTransactionWebhookParsing() {
256257
Assertions.assertEquals("EVJN42272224222B5JB8BRC84N686ZEUR", request.getData().getId());
257258
}
258259

260+
@Test
261+
public void testTransactionWebhookBankCategoryDataParsing() {
262+
String json =
263+
getFileContents(
264+
"mocks/notification/balancePlatform-transaction-created-bank-category.json");
265+
TransactionWebhooksHandler webhookHandler = new TransactionWebhooksHandler(json);
266+
Assertions.assertTrue(webhookHandler.getTransactionNotificationRequestV4().isPresent());
267+
TransactionNotificationRequestV4 request =
268+
webhookHandler.getTransactionNotificationRequestV4().get();
269+
Assertions.assertEquals("EVJN00000000000000000000000003EUR", request.getData().getId());
270+
271+
BankCategoryData bankCategoryData =
272+
request.getData().getTransfer().getCategoryData().getBankCategoryData();
273+
Assertions.assertNotNull(bankCategoryData);
274+
Assertions.assertEquals(BankCategoryData.TypeEnum.BANK, bankCategoryData.getType());
275+
Assertions.assertEquals(BankCategoryData.PriorityEnum.REGULAR, bankCategoryData.getPriority());
276+
}
277+
259278
@Test
260279
public void testNegativeBalanceCompensationWarning() {
261280
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)