Skip to content

Commit ae24225

Browse files
authored
Test for TransferNotificationRequest (#1500)
1 parent 3652510 commit ae24225

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
import com.adyen.model.reportwebhooks.ReportWebhooksHandler;
1515
import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4;
1616
import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler;
17+
import com.adyen.model.transferwebhooks.PlatformPayment;
18+
import com.adyen.model.transferwebhooks.TransferNotificationRequest;
19+
import com.adyen.model.transferwebhooks.TransferWebhooksHandler;
1720
import com.adyen.util.HMACValidator;
1821
import java.security.SignatureException;
1922
import java.util.Optional;
2023
import org.junit.Assert;
2124
import org.junit.Test;
2225

26+
2327
/** Unit testing for all AfP/Bank related webhooks */
2428
public class BalancePlatformWebhooksTest extends BaseTest {
2529

@@ -352,4 +356,31 @@ public void testNetworkTokenUpdatedNotificationRequest() throws Exception {
352356
assertEquals(
353357
"YOUR_BALANCE_PLATFORM", networkTokenNotificationRequest.getData().getBalancePlatform());
354358
}
359+
360+
@Test
361+
public void testTransferNotificationRequest() throws Exception {
362+
String json =
363+
getFileContents(
364+
"mocks/balancePlatform-webhooks/transfer-updated.json");
365+
366+
Optional<TransferNotificationRequest> optionalTransferNotificationRequest =
367+
new TransferWebhooksHandler(json).getTransferNotificationRequest();
368+
assertTrue(optionalTransferNotificationRequest.isPresent());
369+
370+
TransferNotificationRequest transferNotificationRequest =
371+
optionalTransferNotificationRequest.get();
372+
assertEquals(
373+
TransferNotificationRequest.TypeEnum.BALANCEPLATFORM_TRANSFER_UPDATED,
374+
transferNotificationRequest.getType());
375+
assertNotNull(transferNotificationRequest.getData());
376+
assertEquals("YOUR_BALANCE_PLATFORM", transferNotificationRequest.getData().getBalancePlatform());
377+
378+
assertNotNull(transferNotificationRequest.getData().getCategoryData().getPlatformPayment());
379+
assertEquals(PlatformPayment.PlatformPaymentTypeEnum.REMAINDER,
380+
transferNotificationRequest.getData().getCategoryData().getPlatformPayment().getPlatformPaymentType());
381+
382+
assertNotNull(transferNotificationRequest.getData().getBalances());
383+
assertEquals(1, transferNotificationRequest.getData().getBalances().size());
384+
}
385+
355386
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
3+
"data": {
4+
5+
"balancePlatform": "YOUR_BALANCE_PLATFORM",
6+
"creationDate": "2025-06-02T13:46:27+02:00",
7+
"id": "01234",
8+
"accountHolder": {
9+
"description": "The Account Holder",
10+
"id": "AH1234567890"
11+
},
12+
"amount": {
13+
"currency": "EUR",
14+
"value": 22700
15+
},
16+
"balanceAccount": {
17+
"description": "The Liable Balance Account",
18+
"id": "BA1234567890"
19+
},
20+
"category": "platformPayment",
21+
"categoryData": {
22+
"modificationMerchantReference": "<auto>",
23+
"modificationPspReference": "ZX1234567890",
24+
"paymentMerchantReference": "pv-test",
25+
"platformPaymentType": "Remainder",
26+
"pspPaymentReference": "PSP01234",
27+
"type": "platformPayment"
28+
},
29+
"description": "Remainder Fee for pv-test",
30+
"direction": "incoming",
31+
"reason": "approved",
32+
"reference": "<auto>",
33+
"status": "authorised",
34+
"type": "capture",
35+
"balances": [
36+
{
37+
"currency": "EUR",
38+
"received": 0,
39+
"reserved": 22700
40+
}
41+
],
42+
"eventId": "EV1234567890",
43+
"events": [
44+
{
45+
"bookingDate": "2025-06-02T13:46:27+02:00",
46+
"id": "EV1234567890",
47+
"mutations": [
48+
{
49+
"currency": "EUR",
50+
"received": 22700
51+
}
52+
],
53+
"status": "received",
54+
"type": "accounting"
55+
},
56+
{
57+
"bookingDate": "2025-06-02T13:46:27+02:00",
58+
"id": "EV1234567890-2",
59+
"mutations": [
60+
{
61+
"currency": "EUR",
62+
"received": -22700,
63+
"reserved": 22700
64+
}
65+
],
66+
"status": "authorised",
67+
"type": "accounting"
68+
}
69+
],
70+
"sequenceNumber": 2
71+
},
72+
"environment": "test",
73+
"timestamp": "2025-06-02T11:46:28.635Z",
74+
"type": "balancePlatform.transfer.updated"
75+
}

0 commit comments

Comments
 (0)